#define CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ordered_set tree<pair<ll,ll>, null_type, less <pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define sz(s) (int)s.size()
const int N = 2e6 + 10, mod = 1e9 + 7;
const double PI = asin(1.0) * 2;
const int OO = 0x3f3f3f3f;
int dx[]{1, -1, 0, 0, 1, 1, -1, -1};
int dy[]{0, 0, 1, -1, 1, -1, 1, -1};
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void solve() {
int n, m, x, y;
cin >> n >> m;
vector<int> color(n);
map<int, set<int>> mp;
for (auto &i: color)
cin >> i;
for (int i = 0; i < m; i++) {
cin >> x >> y;
x--, y--;
if (color[x] != color[y])
mp[color[x]].insert(color[y]),
mp[color[y]].insert(color[x]);
}
int mx = INT_MIN, col = -1, sz;
for (auto i: mp) {
sz = sz(i.second);
if (mx < sz) {
mx = sz;
col = i.first;
}
}
cout << col;
}
int main() {
fast();
//freopen("abc.in", "r", stdin);
//freopen("output.txt", "w", stdout);
int T = 1;
//cin >> T;
while (T--) {
solve();
}
return 0;
}
I2RlZmluZSBDUlRfU0VDVVJFX05PX1dBUk5JTkdTCgojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPgojaW5jbHVkZSA8ZXh0L3BiX2RzL3RyZWVfcG9saWN5LmhwcD4KCnVzaW5nIG5hbWVzcGFjZSBfX2dudV9wYmRzOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiBsb25nIGRvdWJsZSBsZDsKdH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XV0uaW5zZXJ0KGNvbG9yW3ldKSwKICAgICAgICAgICAgICAgICAgICBtcFtjb2xvclt5XV0uaW5zZXJ0KGNvbG9yW3hdKTsKICAgIH0KICAgIGludCBteCA9IElOVF9NSU4sIGNvbCA9IC0xLCBzejsKICAgIGZvciAoYXV0byBpOiBtcCkgewogICAgICAgIHN6ID0gc3ooaS5zZWNvbmQpOwogICAgICAgIGlmIChteCA8IHN6KSB7CiAgICAgICAgICAgIG14ID0gc3o7CiAgICAgICAgICAgIGNvbCA9IGkuZmlyc3Q7CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBjb2w7Cn0KCmludCBtYWluKCkgewogICAgZmFzdCgpOwogICAgLy9mcmVvcGVuKCJhYmMuaW4iLCAiciIsIHN0ZGluKTsKICAgIC8vZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKICAgIGludCBUID0gMTsKICAgIC8vY2luID4+IFQ7CiAgICB3aGlsZSAoVC0tKSB7CiAgICAgICAgc29sdmUoKTsKICAgIH0KICAgIHJldHVybiAwOwp9