#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 100000000000000
//INF - 1e14
#define vi vector<ll>
#define PB push_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define fer(i, a, n) for( ll i = a; i <= n; i++)
#define fdr(i, a, n) for( ll i = a; i >= n; i--)
#define inint(i) ll i;cin >> i
#define invec(n,v) vi v(n); fer(i,0,n-1) cin >> v[i]
#define insvec(n,v) inint(n); vi v(n); fer(i,0,n-1) cin >> v[i]
#define MK2DV(v,row,col,val) vector<vector<ll> > v(row, vector<ll>(col,val))
#define matrix vector<vector<ll> >
#define printpartition cout << "-------------------------------------------------------------" << endl;
#define printmat(mat,row,col) cout << #mat << "::" << endl; fer(i,0,row-1)fer(j,0,col-1)cout << mat[i][j] << " \n"[j == col-1]; printpartition;
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
ll fast_pow(ll base, ll exp, ll M = MOD) { base = base % M; ll result = 1; while (exp > 0) { if (exp % 2 == 1) result = (result * base) % M; base = (base * base) % M; exp = exp / 2; } return result; }
ll modInverse(ll A, ll M = MOD) { return fast_pow(A, M - 2, M); } // only when M is prime
vector<ll> clr(100000);
vector<ll> prs(100000);
vector<vector<ll> > adj(100000);

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif

	ll n, m;
	cin >> n >> m;
	fer(i, 0, n - 1) {
		cin >> clr[i];
		clr[i]--;
	}

	fer(i, 0, m - 1) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		adj[clr[v]].push_back(clr[u]);
		adj[clr[u]].push_back(clr[v]);
	}
	ll mx = 0, res = clr[0] + 1;
	for (ll i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 100000000000000
//INF - 1e14
#define vi vector<ll>
#define PB push_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define fer(i, a, n) for( ll i = a; i <= n; i++)
#define fdr(i, a, n) for( ll i = a; i >= n; i--)
#define inint(i) ll i;cin >> i
#define invec(n,v) vi v(n); fer(i,0,n-1) cin >> v[i]
#define insvec(n,v) inint(n); vi v(n); fer(i,0,n-1) cin >> v[i]
#define MK2DV(v,row,col,val) vector<vector<ll> > v(row, vector<ll>(col,val))
#define matrix vector<vector<ll> >
#define printpartition cout << "-------------------------------------------------------------" << endl;
#define printmat(mat,row,col) cout << #mat << "::" << endl; fer(i,0,row-1)fer(j,0,col-1)cout << mat[i][j] << " \n"[j == col-1]; printpartition;
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
ll fast_pow(ll base, ll exp, ll M = MOD) { base = base % M; ll result = 1; while (exp > 0) { if (exp % 2 == 1) result = (result * base) % M; base = (base * base) % M; exp = exp / 2; } return result; }
ll modInverse(ll A, ll M = MOD) { return fast_pow(A, M - 2, M); } // only when M is prime
vector<ll> clr(100000);
vector<vector<ll> > adj(100000);

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif

	ll n, m;
	cin >> n >> m;
	fer(i, 0, n - 1) {
		cin >> clr[i];
		clr[i]--;
	}

	fer(i, 0, m - 1) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		if (!binary_search(adj[clr[v]].begin(), adj[clr[v]].end(), clr[u]))
			adj[clr[v]].push_back(clr[u]);
		if (!binary_search(adj[clr[u]].begin(), adj[clr[u]].end(), clr[v]))
			adj[clr[u]].push_back(clr[v]);
		adj[clr[u]].push_back(clr[v]);
	}
	ll mx = 0, res = clr[0] + 1;
	for (ll i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 100000000000000
//INF - 1e14
#define vi vector<ll>
#define PB push_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define fer(i, a, n) for( ll i = a; i <= n; i++)
#define fdr(i, a, n) for( ll i = a; i >= n; i--)
#define inint(i) ll i;cin >> i
#define invec(n,v) vi v(n); fer(i,0,n-1) cin >> v[i]
#define insvec(n,v) inint(n); vi v(n); fer(i,0,n-1) cin >> v[i]
#define MK2DV(v,row,col,val) vector<vector<ll> > v(row, vector<ll>(col,val))
#define matrix vector<vector<ll> >
#define printpartition cout << "-------------------------------------------------------------" << endl;
#define printmat(mat,row,col) cout << #mat << "::" << endl; fer(i,0,row-1)fer(j,0,col-1)cout << mat[i][j] << " \n"[j == col-1]; printpartition;
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
ll fast_pow(ll base, ll exp, ll M = MOD) { base = base % M; ll result = 1; while (exp > 0) { if (exp % 2 == 1) result = (result * base) % M; base = (base * base) % M; exp = exp / 2; } return result; }
ll modInverse(ll A, ll M = MOD) { return fast_pow(A, M - 2, M); } // only when M is prime
vector<ll> clr(100000);
vector<vector<ll> > adj(100000);

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif

	ll n, m;
	cin >> n >> m;
	fer(i, 0, n - 1) {
		cin >> clr[i];
		clr[i]--;
	}

	fer(i, 0, m - 1) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		if (!binary_search(adj[clr[v]].begin(), adj[clr[v]].end(), clr[u]))
			adj[clr[v]].push_back(clr[u]);
		if (!binary_search(adj[clr[u]].begin(), adj[clr[u]].end(), clr[v]))
			adj[clr[u]].push_back(clr[v]);
	}
	ll mx = 0, res = clr[0] + 1;
	for (ll i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 100000000000000
//INF - 1e14
#define vi vector<ll>
#define PB push_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define fer(i, a, n) for( ll i = a; i <= n; i++)
#define fdr(i, a, n) for( ll i = a; i >= n; i--)
#define inint(i) ll i;cin >> i
#define invec(n,v) vi v(n); fer(i,0,n-1) cin >> v[i]
#define insvec(n,v) inint(n); vi v(n); fer(i,0,n-1) cin >> v[i]
#define MK2DV(v,row,col,val) vector<vector<ll> > v(row, vector<ll>(col,val))
#define matrix vector<vector<ll> >
#define printpartition cout << "-------------------------------------------------------------" << endl;
#define printmat(mat,row,col) cout << #mat << "::" << endl; fer(i,0,row-1)fer(j,0,col-1)cout << mat[i][j] << " \n"[j == col-1]; printpartition;
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
ll fast_pow(ll base, ll exp, ll M = MOD) { base = base % M; ll result = 1; while (exp > 0) { if (exp % 2 == 1) result = (result * base) % M; base = (base * base) % M; exp = exp / 2; } return result; }
ll modInverse(ll A, ll M = MOD) { return fast_pow(A, M - 2, M); } // only when M is prime
vector<ll> clr(100000);
vector<set<ll> > adj(100000);

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif

	ll n, m;
	cin >> n >> m;
	fer(i, 0, n - 1) {
		cin >> clr[i];
		clr[i]--;
	}

	fer(i, 0, m - 1) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		adj[clr[v]].insert(clr[u]);
		adj[clr[u]].insert(clr[v]);
	}
	ll mx = 0, res = clr[0] + 1;
	for (ll i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> clr(100000);
vector<set<int> > adj(100000);
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> clr[i];
		clr[i]--;
	}
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		adj[clr[v]].insert(clr[u]);
		adj[clr[u]].insert(clr[v]);
	}
	int mx = 0, res = clr[0] + 1;
	for (int i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> clr(100000);
vector<vector<int> > adj(100000);
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> clr[i];
		clr[i]--;
	}
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		if (!binary_search(adj[clr[v]].begin(), adj[clr[v]].end(), clr[u]))
			adj[clr[v]].push_back(clr[u]);
		if (!binary_search(adj[clr[u]].begin(), adj[clr[u]].end(), clr[v]))
			adj[clr[u]].push_back(clr[v]);
	}
	int mx = 0, res = clr[0] + 1;
	for (int i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 100000000000000
//INF - 1e14
#define vi vector<ll>
#define PB push_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define fer(i, a, n) for( ll i = a; i <= n; i++)
#define fdr(i, a, n) for( ll i = a; i >= n; i--)
#define inint(i) ll i;cin >> i
#define invec(n,v) vi v(n); fer(i,0,n-1) cin >> v[i]
#define insvec(n,v) inint(n); vi v(n); fer(i,0,n-1) cin >> v[i]
#define MK2DV(v,row,col,val) vector<vector<ll> > v(row, vector<ll>(col,val))
#define matrix vector<vector<ll> >
#define printpartition cout << "-------------------------------------------------------------" << endl;
#define printmat(mat,row,col) cout << #mat << "::" << endl; fer(i,0,row-1)fer(j,0,col-1)cout << mat[i][j] << " \n"[j == col-1]; printpartition;
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
ll fast_pow(ll base, ll exp, ll M = MOD) { base = base % M; ll result = 1; while (exp > 0) { if (exp % 2 == 1) result = (result * base) % M; base = (base * base) % M; exp = exp / 2; } return result; }
ll modInverse(ll A, ll M = MOD) { return fast_pow(A, M - 2, M); } // only when M is prime
vector<ll> clr(100000);
vector<set<ll> > adj(100000);

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("intt.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
#endif

	ll n, m;
	cin >> n >> m;
	fer(i, 0, n - 1) {
		cin >> clr[i];
		clr[i]--;
	}

	fer(i, 0, m - 1) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		if (clr[u] == clr[v]) continue;
		// if (!binary_search(adj[clr[v]].begin(), adj[clr[v]].end(), clr[u]))
		adj[clr[v]].insert(clr[u]);
		// if (!binary_search(adj[clr[u]].begin(), adj[clr[u]].end(), clr[v]))
		adj[clr[u]].insert(clr[v]);
	}
	ll mx = 0, res = clr[0] + 1;
	for (ll i = 0; i < n; i++) {
		if (adj[clr[i]].size() >= mx) {
			if (adj[clr[i]].size() == mx)
				res = min(clr[i] + 1, res);
			else
				res = clr[i] + 1;
			mx = adj[clr[i]].size();
		}
	}
	cout << res;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,long long int> mp;
    int vertices,edges;
    long long int check=0;
    int ans=INT_MAX;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
        mp[a]=0;
    }
    int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
    }
 map<int,long long int>:: iterator ii;
 check=mp[ans];
 for(ii=mp.begin();ii!=mp.end();ii++)
 {
     if(ii->second > check)
     {
         check=ii->second;
         ans=ii->first;
     }
 }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int> mp;
   unordered_map<string,int> dp;
    int vertices,edges;
    int check=0;
    int ans=INT_MAX;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
        mp[a]=0;
    }
    int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       string aa=to_string (v[a]);
       string bb=to_string (v[b]);
       if(dp[aa+bb]==1 || dp[bb+aa]==1)
       continue;

       else
       {
           dp[aa+bb]=1;
           dp[bb+aa]=1;
       }
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
    }
 map<int,int>:: iterator ii;
 check=mp[ans];
 for(ii=mp.begin();ii!=mp.end();ii++)
 {
     if(ii->second > check)
     {
         check=ii->second;
         ans=ii->first;
     }
 }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
unordered_map<int,int> mp;
    int vertices,edges;
    int check=-1,ans;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
    }
     int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
       if(check<mp[v[a]])
       {
           check=mp[v[a]];
           ans=v[a];
       }
       if(check< mp[v[b]])
       {
           check =  mp[v[b]];
           ans=v[b];
       }
    }
   // cout<<mp[2]<<" "<<mp[4]<<" ";
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int> mp;
   unordered_map<string,int> dp;
    int vertices,edges;
    int check=0;
    int ans=INT_MAX;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
        mp[a]=0;
    }
    int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       string aa=to_string (a);
       string bb=to_string (b);
       if(dp[aa+bb]==1 || dp[bb+aa]==1)
       continue;

       else
       {
           dp[aa+bb]=1;
           dp[bb+aa]=1;
       }
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
    }
 map<int,int>:: iterator ii;
 check=mp[ans];
 for(ii=mp.begin();ii!=mp.end();ii++)
 {
     if(ii->second > check)
     {
         check=ii->second;
         ans=ii->first;
     }
 }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
unordered_map<int,int> mp;
    int vertices,edges;
    int check=-1,ans;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
    }
     int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       if(v[a]!=v[b])
       {
           mp[a]++;
           mp[b]++;
       }
       if(check<mp[a])
       {
           check=mp[a];
           ans=a;
       }
       if(check<mp[b])
       {
           check = mp[b];
           ans=b;
       }
    }
    cout<<v[ans];
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int> mp;
   unordered_map<string,int> dp;
    int vertices,edges;
    int check=0;
    int ans=INT_MAX;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
    }
    int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       string aa=to_string (v[a]);
       string bb=to_string (v[b]);
       if(dp[aa+'#'+bb]==1 || dp[bb+'#'+aa]==1)
       continue;

       else
       {
           if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
           dp[aa+'#'+bb]=1;
           dp[bb+'#'+aa]=1;
       }

    }
 map<int,int>:: iterator ii;
 check=mp[ans];
 for(ii=mp.begin();ii!=mp.end();ii++)
 {
     if(ii->second > check)
     {
         check=ii->second;
         ans=ii->first;
     }
 }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,long long int> mp;
    int vertices,edges;
    long long int check=0;
    int ans=0;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
        mp[a]=0;
    }
    int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
    }
 map<int,long long int>:: iterator ii;

 for(ii=mp.begin();ii!=mp.end();ii++)
 {
     if(ii->second > check)
     {
         check=ii->second;
         ans=ii->first;
     }
 }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,long long int> mp;
    int vertices,edges;
    long long int check=0;
    int ans=INT_MAX;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
        mp[a]=0;
    }
    int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
    }
 map<int,long long int>:: iterator ii;

 for(ii=mp.begin();ii!=mp.end();ii++)
 {
     if(ii->second > check)
     {
         check=ii->second;
         ans=ii->first;
     }
 }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int> mp;
   unordered_map<string,int> dp;
    int vertices,edges;
    int check=0;
    int ans=INT_MAX;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
    }
    int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       string aa=to_string (v[a]);
       string bb=to_string (v[b]);
       if(dp[aa+bb]==1 || dp[bb+aa]==1)
       continue;

       else
       {
           if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
           dp[aa+bb]=1;
           dp[bb+aa]=1;
       }

    }
 map<int,int>:: iterator ii;
 check=mp[ans];
 for(ii=mp.begin();ii!=mp.end();ii++)
 {
     if(ii->second > check)
     {
         check=ii->second;
         ans=ii->first;
     }
 }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
unordered_map<int,int> mp;
    int vertices,edges;
    int check=-1,ans;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
    }
     int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
       if((check==mp[v[a]] && v[a]<ans) || check<mp[v[a]] )
       {

           check=mp[v[a]];
           ans=v[a];
       }
       if(check<=mp[v[b]])
       {
            if(check==mp[v[b]] && v[b]>ans)
           continue;
           check =  mp[v[b]];
           ans=v[b];
       }
    }
   // cout<<mp[2]<<" "<<mp[4]<<" ";
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
unordered_map<int,int> mp;
    int vertices,edges;
    int check=0,ans=INT_MAX;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
    }
     int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
       if((check==mp[v[a]] && v[a]<ans) || check<mp[v[a]] )
       {

           check=mp[v[a]];
           ans=v[a];
       }
       if(check<=mp[v[b]])
       {
            if(check==mp[v[b]] && v[b]>ans)
           continue;
           check =  mp[v[b]];
           ans=v[b];
       }
    }
   // cout<<mp[2]<<" "<<mp[4]<<" ";
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int> mp;
    int vertices,edges;
    int check=0,ans;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
        mp[a]=0;
    }
    int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
    }
 map<int,int>:: iterator ii;

 for(ii=mp.begin();ii!=mp.end();ii++)
 {
     if(ii->second > check)
     {
         check=ii->second;
         ans=ii->first;
     }
 }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
unordered_map<int,int> mp;
    int vertices,edges;
    int check=0,ans=INT_MAX;
    cin>>vertices>>edges;
    vector<int> v;
    v.push_back(0);
    for(int i=1;i<=vertices;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
        ans=min(ans,a);
    }
     int a,b;
    for(int i=0;i<edges;i++)
    {
       cin>>a>>b;
       if(v[a]!=v[b])
       {
           mp[v[a]]++;
           mp[v[b]]++;
       }
       if((check==mp[v[a]] && v[a]<ans) || check<mp[v[a]] )
       {

           check=mp[v[a]];
           ans=v[a];
       }
       if((check==mp[v[b]] && v[b]<ans) || check<mp[v[b]] )
       {
           check =  mp[v[b]];
           ans=v[b];
       }
    }
   // cout<<mp[2]<<" "<<mp[4]<<" ";
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;

int n,m;

signed main()
{
    cin >> n >> m;

    int c[n+1];
    map<int,int > num;
    map<int,string > bitmask;
    for(int i = 1; i<=n; i++)
    {
        cin >> c[i];
    }

    string temp = "";
    for(int i = 0; i < 1000001; i++)
    {
        temp.push_back('0');
    }

    for(int i = 1; i<=n; i++)
    {
        bitmask[c[i]] = temp;
    }

    int a,b;
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        if(bitmask[c[a]][c[b]]=='0' && c[a]!=c[b])
        {
            bitmask[c[a]][c[b]] = '1';
            bitmask[c[b]][c[a]] = '1';
            num[c[a]]++;
            num[c[b]]++;
        }
    }

    int y;
    int ans = 0;
    for(int i = 1; i<=n; i++)
    {
        if(ans>=num[c[i]])
        {
            y = c[i];
        }
    }

    cout << y << endl;
}


#include <bits/stdc++.h>

using namespace std;

signed main()
{
    int n,m;
    cin >> n >> m;
    int c[n+1];
    int maxcol = 0;
    for(int i = 1; i<=n; i++)
    {
        cin >> c[i];
        maxcol = max(maxcol, c[i]);
    }

    set<int> G[maxcol+1];

    int a,b;
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;

        if(c[a]!=c[b])
        {
            G[c[a]].insert(c[b]);
            G[c[b]].insert(c[a]);
        }

    }

    int colour = c[1];
    int num = G[c[1]].size();

    for(int i = 1; i<=n; i++)
    {
        if(num<G[c[i]].size() || (num==G[c[i]].size() && colour>c[i]))
        {
            colour = c[i];
            num = G[c[i]].size();
        }
    }

    cout << colour << endl;

}


#include <bits/stdc++.h>

using namespace std;

int n,m;

signed main()
{
    cin >> n >> m;

    int c[n+1];
    map<int,int > num;
    map<int,string > bitmask;
    for(int i = 1; i<=n; i++)
    {
        cin >> c[i];
    }

    string temp = "";
    for(int i = 0; i < 1000001; i++)
    {
        temp.push_back('0');
    }

    for(int i = 1; i<=n; i++)
    {
        bitmask[c[i]] = temp;
    }

    int a,b;
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        if(bitmask[c[a]][c[b]]=='0' && c[a]!=c[b])
        {
            bitmask[c[a]][c[b]] = '1';
            bitmask[c[b]][c[a]] = '1';
            num[c[a]]++;
            num[c[b]]++;
        }
    }

    int y = c[1];
    int ans = num[c[1]];
    for(int i = 1; i<=n; i++)
    {
        if(ans<num[c[i]] || (ans==num[c[i]] && y>c[i]))
        {
            ans = num[c[i]];
            y = c[i];
        }

    }

    cout << y << endl;
}


#include <bits/stdc++.h>

using namespace std;

int n,m;

signed main()
{
    cin >> n >> m;

    int c[n+1];
    map<int,int > num;
    map<int,string > bitmask;
    for(int i = 1; i<=n; i++)
    {
        cin >> c[i];
    }

    string temp = "";
    for(int i = 0; i < 1000001; i++)
    {
        temp.push_back('0');
    }

    for(int i = 1; i<=n; i++)
    {
        bitmask[c[i]] = temp;
    }

    int a,b;
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        if(bitmask[c[a]][c[b]]=='0' && c[a]!=c[b])
        {
            bitmask[c[a]][c[b]] = '1';
            bitmask[c[b]][c[a]] = '1';
            num[c[a]]++;
            num[c[b]]++;
        }
    }

    int y;
    int ans = 0;
    for(auto x: num)
    {
        if(ans<x.second){
            y = x.first;
            ans = max(x.second,ans);
        }
    }

    cout << y << endl;
}


#include <bits/stdc++.h>

using namespace std;

int n,m;

signed main()
{
    cin >> n >> m;

    int c[n+1];
    map<int,int > num;
    map<int,string > bitmask;
    for(int i = 1; i<=n; i++)
    {
        cin >> c[i];
    }

    string temp = "";
    for(int i = 0; i < 1000001; i++)
    {
        temp.push_back('0');
    }

    for(int i = 1; i<=n; i++)
    {
        bitmask[c[i]] = temp;
    }

    int a,b;
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        if(bitmask[c[a]][c[b]]=='0' && c[a]!=c[b])
        {
            bitmask[c[a]][c[b]] = '1';
            bitmask[c[b]][c[a]] = '1';
            num[c[a]]++;
            num[c[b]]++;
        }
    }

    int y = c[1];
    int ans = num[c[1]];
    for(auto x: num)
    {
        if(ans<x.second){
            y = x.first;
            ans = max(x.second,ans);
        }
    }

    cout << y << endl;
}


#include <bits/stdc++.h>

using namespace std;

int n,m;

signed main()
{
    cin >> n >> m;

    int c[n+1];
    map<int,int > num;
    map<int,string > bitmask;
    for(int i = 1; i<=n; i++)
    {
        cin >> c[i];
    }

    string temp = "";
    for(int i = 0; i < 1000001; i++)
    {
        temp.push_back('0');
    }

    for(int i = 1; i<=n; i++)
    {
        bitmask[c[i]] = temp;
    }

    int a,b;
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        if(bitmask[c[a]][c[b]]=='0' && c[a]!=c[b])
        {
            bitmask[c[a]][c[b]] = '1';
            bitmask[c[b]][c[a]] = '1';
            num[c[a]]++;
            num[c[b]]++;
        }
    }

    int y = c[1];
    int ans = num[c[1]];
    for(int i = 1; i<=n; i++)
    {
        if(ans<=num[c[i]])
        {
            ans = num[c[i]];
            y = c[i];
        }
    }

    cout << y << endl;
}


#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define rz resize
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,mno;
	cin>>n>>mno;
	vector<ll> c(n+1);
	f(i,1,n+1)
		cin>>c[i];
	map<ll,ll> m;
	bool flag=0;
	f(i,0,mno)
	{
		int a,b;
		cin>>a>>b;
		if(c[a]!=c[b])
			m[c[a]]++,m[c[b]]++,flag=1;
	}
	if(!flag)
	{
		ll mn=1e15;
		f(i,0,n)
			mn=min(mn,c[i+1]);
		cout<<mn<<"\n";
		return 0;
	}
	ll tot_col,tot_cnt=-1;
	for(auto it=m.begin();it!=m.end();it++)
	{
		ll cur_col=it->ff,cur_cnt=it->ss;
		if(tot_cnt<cur_cnt)
			tot_col=cur_col,tot_cnt=cur_cnt;
		else if(cur_cnt==tot_cnt && cur_col<tot_col)
			tot_col=cur_col;
	}
	if(n==1000 && mno==90604)
		cout<<m[1]<<m[6];
	cout<<tot_col<<"\n";
}


#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define rz resize
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,mno;
	cin>>n>>mno;
	vector<ll> c(n+1);
	f(i,1,n+1)
		cin>>c[i];
	map<ll,ll> m;
	bool flag=0;
	f(i,0,mno)
	{
		int a,b;
		cin>>a>>b;
		if(c[a]!=c[b])
			m[c[a]]++,m[c[b]]++,flag=1;
	}
	if(!flag)
	{
		ll mn=1e15;
		f(i,0,n)
			mn=min(mn,c[i+1]);
		cout<<mn<<"\n";
		return 0;
	}
	ll tot_col,tot_cnt=-1;
	for(auto it=m.begin();it!=m.end();it++)
	{
		ll cur_col=it->ff,cur_cnt=it->ss;
		if(tot_cnt<cur_cnt)
			tot_col=cur_col,tot_cnt=cur_cnt;
		else if(cur_cnt==tot_cnt && cur_col<tot_col)
			tot_col=cur_col;
	}
	cout<<tot_col<<"\n";
}


#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define rz resize
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,mno;
	cin>>n>>mno;
	vector<ll> c(n+1);
	f(i,1,n+1)
		cin>>c[i];
	map<ll,set<int> > m;
	bool flag=0;
	f(i,0,mno)
	{
		int a,b;
		cin>>a>>b;
		if(c[a]!=c[b])
			flag=1,m[c[a]].insert(c[b]),m[c[b]].insert(c[a]);
	}
	if(!flag)
	{
		ll mn=1e15;
		f(i,0,n)
			mn=min(mn,c[i+1]);
		cout<<mn<<"\n";
		return 0;
	}
	ll tot_col,tot_cnt=-1;
	for(auto it=m.begin();it!=m.end();it++)
	{
		ll cur_col=it->ff,cur_cnt;
		cur_cnt=sz(m[cur_col]);
		if(tot_cnt<cur_cnt)
			tot_col=cur_col,tot_cnt=cur_cnt;
		else if(cur_cnt==tot_cnt && cur_col<tot_col)
			tot_col=cur_col;
	}
	// if(n==1000 && mno==90604)
	// 	cout<<m[1]<<' '<<m[6]<<' ';
	cout<<tot_col<<"\n";
}


#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define rz resize
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,mno;
	cin>>n>>mno;
	vector<ll> c(n+1);
	f(i,1,n+1)
		cin>>c[i];
	map<ll,ll> m;
	bool flag=0;
	f(i,0,mno)
	{
		int a,b;
		cin>>a>>b;
		if(c[a]!=c[b])
			m[c[a]]++,m[c[b]]++,flag=1;
	}
	if(!flag)
	{
		ll mn=1e15;
		f(i,0,n)
			mn=min(mn,c[i+1]);
		cout<<mn<<"\n";
		return 0;
	}
	ll tot_col,tot_cnt=-1;
	for(auto it=m.begin();it!=m.end();it++)
	{
		ll cur_col=it->ff,cur_cnt=it->ss;
		if(tot_cnt<cur_cnt)
			tot_col=cur_col,tot_cnt=cur_cnt;
		else if(cur_cnt==tot_cnt && cur_col<tot_col)
			tot_col=cur_col;
	}
	if(n==1000 && mno==90604)
		cout<<m[1]<<' '<<m[6]<<' ';
	cout<<tot_col<<"\n";
}


#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define rz resize
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,mno;
	cin>>n>>mno;
	vector<ll> c(n+1);
	f(i,1,n+1)
		cin>>c[i];
	map<ll,ll> m;
	bool flag=0;
	f(i,0,mno)
	{
		int a,b;
		cin>>a>>b;
		if(c[a]!=c[b])
			m[c[a]]++,m[c[b]]++,flag=1;
	}
	if(!flag)
	{
		ll mn=1e15;
		f(i,0,n)
			mn=min(mn,c[i+1]);
		cout<<mn<<"\n";
		return 0;
	}
	ll tot_col,tot_cnt=-1;
	for(auto it=m.begin();it!=m.end();it++)
	{
		ll cur_col=it->ff,cur_cnt=it->ss;
		if(tot_cnt<cur_cnt)
			tot_col=cur_col,tot_cnt=cur_cnt;
		else if(cur_cnt==tot_cnt && cur_col<tot_col)
			tot_col=cur_col;
	}
	if(n==1000 && k==90604)
		cout<<m[1]<<m[6];
	cout<<tot_col<<"\n";
}


#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define rz resize
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,mno;
	cin>>n>>mno;
	vector<ll> c(n+1);
	f(i,1,n+1)
		cin>>c[i];
	map<ll,ll> m;
	f(i,0,mno)
	{
		int a,b;
		cin>>a>>b;
		if(c[a]!=c[b])
			m[c[a]]++,m[c[b]]++;
	}
	ll tot_col,tot_cnt=-1;
	for(auto it=m.begin();it!=m.end();it++)
	{
		ll cur_col=it->ff,cur_cnt=it->ss;
		if(tot_cnt<cur_cnt)
			tot_col=cur_col,tot_cnt=cur_cnt;
		else if(cur_cnt==tot_cnt && cur_col<tot_col)
			tot_col=cur_col;
	}
	cout<<tot_col<<"\n";
}


#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define rz resize
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,mno;
	cin>>n>>mno;
	vector<ll> c(n+1);
	f(i,1,n+1)
		cin>>c[i];
	map<ll,set<int> > m;
	bool flag=0;
	f(i,0,mno)
	{
		int a,b;
		cin>>a>>b;
		if(c[a]!=c[b])
			m[c[a]].insert(c[b]),m[c[b]].insert(c[a]);
	}
	// if(!flag)
	// {
	// 	ll mn=1e15;
	// 	f(i,0,n)
	// 		mn=min(mn,c[i+1]);
	// 	cout<<mn<<"\n";
	// 	return 0;
	// }
	ll tot_col,tot_cnt=-1;
	for(auto it=m.begin();it!=m.end();it++)
	{
		ll cur_col=it->ff,cur_cnt;
		cur_cnt=sz(m[cur_col]);
		if(tot_cnt<cur_cnt)
			tot_col=cur_col,tot_cnt=cur_cnt;
		else if(cur_cnt==tot_cnt && cur_col<tot_col)
			tot_col=cur_col;
	}
	// if(n==1000 && mno==90604)
	// 	cout<<m[1]<<' '<<m[6]<<' ';
	cout<<tot_col<<"\n";
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    vector<int> adj[n+5];
    for( i=1;i<n;i++){
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    queue<int> q;
    int par[n+5];
    bool v[n+5]={0};
    q.push(1);
    v[1]=1;
    while(!q.empty()){
        int y=q.front();
        q.pop();
        for(i=0;i<adj[y].size();i++){
            if(!v[adj[y][i]]){
                v[adj[y][i]]=1;
                par[adj[y][i]]=y;
                q.push(adj[y][i]);
            }
        }
    }
    int arr[n+5],pos[n+5],prev=0;
    for(i=0;i<n;i++){
        cin>>arr[i];
        pos[arr[i]]=i;
    }
    if(arr[0]!=1){
        cout<<"No";
        exit(0);
    }
    int j=1;
    q.push(1);
    for(i=1;i<n;i++){
    //        cout<<<<endl;
        int temp=adj[q.front()].size();
        if(q.front()!=1){
            temp=adj[q.front()].size()-1;
        }
     //   cout<<q.front()<<" "<<temp<<endl;
  //  cout<<i<<" "<<prev+1<<" "<<prev+temp<<" "<<q.front()<<endl;
        if(pos[arr[i]]<=prev||pos[arr[i]]>prev+temp){
      //      cout<<i<<" "<<arr[i]<<" "<<pos[arr[i]]<<" "<<prev<<" "<<prev+temp+1<<endl;
            cout<<"No";
            exit(0);
        }
        if(q.front()!=par[arr[i]]){
            cout<<"No";
            exit(0);
        }
        if(i==prev+temp){
     //       cout<<"    "<<q.front()<<" "<<prev+1<<" "<<prev+temp<<endl;

            prev+=adj[q.front()].size();
            if(q.front()!=1){
                prev--;
            }
            q.pop();
            q.push(arr[j]);
            j++;
           // cout<<
        }
    }
    cout<<"Yes"<<endl;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int c[n+5]={0},check[200000]={0};
    for(int i=1;i<=n;i++){
        cin>>c[i];
        check[c[i]]++;
    }
    int ans[200000]={0};
    map<pair<int,int>,int> mp;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        if(c[u]==c[v]){
            continue;
        }
        pair<int,int> pr=make_pair(max(u,v),min(u,v));
        if(mp.find(pr)==mp.end()){
            mp.insert(make_pair(pr,1));
            ans[c[u]]++;
            ans[c[v]]++;
        }
    }
    int maxx=-1,ind=1;
    for(int i=1;i<200000;i++){
        if(maxx<ans[i]&&check[i]!=0){
            maxx=ans[i];
            ind=i;
        }
    }
    cout<<ind<<endl;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int c[n+5];
    for(int i=1;i<=n;i++){
        cin>>c[i];
    }
    int ans[n+5]={0};
    map<pair<int,int>,int> mp;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        if(c[u]==c[v]){
            continue;
        }
        pair<int,int> pr=make_pair(u,v);
        if(mp.find(pr)==mp.end()){
            mp.insert(make_pair(pr,1));
            ans[c[u]]++;
            ans[c[v]]++;
        }
    }
    int maxx=0,ind;
    for(int i=1;i<=n;i++){
        if(maxx<=ans[i]){
            maxx=ans[i];
            ind=i;
        }
    }
    cout<<ind<<endl;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int c[n+5]={0},check[200000]={0};
    for(int i=1;i<=n;i++){
        cin>>c[i];
        check[c[i]]++;
    }
    int ans[200000]={0};
    map<pair<int,int>,int> mp;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        if(c[u]==c[v]){
            continue;
        }
        pair<int,int> pr=make_pair(max(u,v),min(u,v));
        if(mp.find(pr)==mp.end()){
            mp.insert(make_pair(pr,1));
            ans[c[u]]++;
            ans[c[v]]++;
        }
    }
    int maxx=-1,ind=1;
    for(int i=1;i<20;i++){
        if(maxx<ans[i]&&check[i]!=0){
            maxx=ans[i];
            ind=i;
        }
    }
    cout<<ind<<endl;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int c[n+5];
    for(int i=1;i<=n;i++){
        cin>>c[i];
    }
    int ans[n+5]={0};
    map<pair<int,int>,int> mp;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        if(c[u]==c[v]){
            continue;
        }
        pair<int,int> pr=make_pair(u,v);
        if(mp.find(pr)==mp.end()){
            mp.insert(make_pair(pr,1));
            ans[c[u]]++;
            ans[c[v]]++;
        }
    }
    int maxx=0,ind;
    for(int i=1;i<=n;i++){
        if(maxx<ans[i]){
            maxx=ans[i];
            ind=i;
        }
    }
    cout<<ind<<endl;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int c[n+5]={0},check[100005]={0};
    for(int i=1;i<=n;i++){
        cin>>c[i];
        check[c[i]]=1;
    }
    int ans[100005]={0};
    map<pair<int,int>,int> mp;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        if(c[u]==c[v]){
            continue;
        }
        pair<int,int> pr=make_pair(max(u,v),min(u,v));
        if(mp.find(pr)==mp.end()){
            mp.insert(make_pair(pr,1));
            ans[c[u]]++;
            ans[c[v]]++;
        }
    }
    int maxx=-1,ind=0;
    for(int i=1;i<100005;i++){
        if(maxx<ans[i]&&check[i]!=0){
            maxx=ans[i];
            ind=i;
        }
    }
    cout<<ind<<endl;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int c[n+5]={0},check[100005]={0};
    for(int i=1;i<=n;i++){
        cin>>c[i];
        check[c[i]]=1;
    }
    int ans[100005]={0};
    map<pair<int,int>,int> mp;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        if(c[u]==c[v]){
            continue;
        }
        pair<int,int> pr=make_pair(max(c[u],c[v]),min(c[u],c[v]));
        if(mp.find(pr)==mp.end()){
            mp.insert(make_pair(pr,1));
            ans[c[u]]++;
            ans[c[v]]++;
        }
    }
    int maxx=-1,ind=0;
    for(int i=1;i<100005;i++){
        if(maxx<ans[i]&&check[i]!=0){
            maxx=ans[i];
            ind=i;
        }
    }
    cout<<ind<<endl;
}


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
class graph
{
public :
    int v;
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
    graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
        col=new int[v];
        ar= new set<int>[(int)1e5+1];
        vis=new bool[v];
        for(int i=0;i<v;i++)vis[i]=false;
    }
    void addedge(int a,int b)
    {
        l[a].push_back(b);
        l[b].push_back(a);
    }

    void dfs(int node) {
        //cout<<node<<endl;
        vis[node] = true;
        for (int i:l[node]) {
            //cout<<col[node]<<" "<<col[i]<<" "<<node<<" "<<i<<endl;
            if (!vis[i]) {
                dfs(i);
            }
            if (col[node] != col[i]) {
                ar[col[node]].insert(col[i]);
                ar[col[i]].insert(col[node]);
                //cout << "ehllo" << endl;
                // cout<<node<<" "<<i<<endl;}
                //cout<<node<<" "<<i<<endl;
            }
        }
    }
    void dfshelp(int src)
    {
        //ool vis[v];
        //fill(vis,vis+v,false);
        //for(int i=0;i<v;i++)vis[i]=false;
        //cout<<src<<endl;
        dfs(src);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int i;
    graph g(n+1);
    set<int> pp;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
        pp.insert(g.col[i]);
        //cout<<g.col[i]<<endl;
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<i<<endl;
        //cout<<a<<" "<<b<<endl;

    }
    //cout<<"SDsd";

    g.dfshelp(1);

    int max=0;
    int cool=INT_MAX;

    for(auto it=pp.begin();it!=pp.end();++it)
    {
        if(g.ar[*it].size()>=max)
        {
            cool=min(cool,*it);
            max=g.ar[*it].size();
        }
        //  cout<<*it<<" "<<max<<endl;
    }

    if(cool==INT_MAX)
    {
        cool=INT_MAX;
        for(i=1;i<=n;i++)
        {
            if(!g.vis[i])
            {
                cool=min(cool,g.col[i]);
                //break;
            }
        }
    }
    if(cool==INT_MAX)
    {
        cool=g.col[1];
    }
    cout<<cool<<endl;
    return 0;
}


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
class graph
{
public :
    int v;
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
    graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
        col=new int[v];
        ar= new set<int>[(int)1e5+1];
        vis=new bool[v];
        for(int i=0;i<v;i++)vis[i]=false;
    }
    void addedge(int a,int b)
    {
        l[a].push_back(b);
        l[b].push_back(a);
    }

    void dfs(int node) {
        //cout<<node<<endl;
        vis[node] = true;
        for (int i:l[node]) {
            //cout<<col[node]<<" "<<col[i]<<" "<<node<<" "<<i<<endl;
            if (!vis[i]) {
                dfs(i);
            }
            if (col[node] != col[i]) {
                ar[col[node]].insert(col[i]);
                ar[col[i]].insert(col[node]);
                //cout << "ehllo" << endl;
                // cout<<node<<" "<<i<<endl;}
                //cout<<node<<" "<<i<<endl;
            }
        }
    }
    void dfshelp(int src)
    {
        //ool vis[v];
        //fill(vis,vis+v,false);
        //for(int i=0;i<v;i++)vis[i]=false;
        //cout<<src<<endl;
        dfs(src);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int i;
    graph g(n+1);
    set<int> pp;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
        pp.insert(g.col[i]);
        //cout<<g.col[i]<<endl;
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<i<<endl;
        //cout<<a<<" "<<b<<endl;

    }
    //cout<<"SDsd";

    g.dfshelp(1);

    int max=0;
    int cool=0;

    for(auto it=pp.begin();it!=pp.end();++it)
    {
        if(g.ar[*it].size()>max)
        {
            cool=*it;
            max=g.ar[*it].size();
        }
      //  cout<<*it<<" "<<max<<endl;
    }
    if(cool==0)
    {
        for(i=1;i<=n;i++)
        {
            if(!g.vis[i])
            {
                cool=g.col[i];
                break;
            }
        }
    }
    if(cool==0)
    {
        cool=g.col[1];
    }
    cout<<cool<<endl;
   return 0;
  }


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long

using namespace std;

class graph
{
public :
    int v;
    //vector<int> list[(int)1e5+1];
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
    graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
        col=new int[v];
        ar= new set<int>[(int)1e5+1];
        vis=new bool[v];
    }
    void addedge(int a,int b)
    {
        l[a].push_back(b);
        l[b].push_back(a);
    }

    void dfs(int node) {
        //cout<<node<<endl;
        vis[node] = true;
        for (int i:l[node]) {
            //cout<<col[node]<<" "<<col[i]<<" "<<node<<" "<<i<<endl;
            if (!vis[i]) {
                dfs(i);
            }
            if (col[node] != col[i]) {
                ar[col[node]].insert(col[i]);
                ar[col[i]].insert(col[node]);
                //cout << "ehllo" << endl;
                // cout<<node<<" "<<i<<endl;}
                //cout<<node<<" "<<i<<endl;
            }
        }
    }
    void dfshelp(int src)
    {
        //ool vis[v];
        //fill(vis,vis+v,false);
        //for(int i=0;i<v;i++)vis[i]=false;
        //cout<<src<<endl;
        dfs(src);
    }
};

int main()
{
    int n,m;
    cin>>n>>m;
    int i;
    graph g(n+1);
    set<int> pp;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
        pp.insert(g.col[i]);
        //cout<<g.col[i]<<endl;
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<i<<endl;

    }
    //cout<<"SDsd";

    g.dfshelp(1);

    int max=0;
    int cool=0;

    for(auto it:pp)
    {
        if(g.ar[it].size()>max)
        {
            cool=it;
            max=g.ar[it].size();
        }
        //cout<<it<<" "<<max<<endl;
    }
    if(cool==0)
    {
        for(i=1;i<=n;i++)
        {
            if(!g.vis[i])
            {
                cool=g.col[i];
                break;
            }
        }
    }
    cout<<cool<<endl;
   return 0;
  }


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
class graph
{
public :
    int v;
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
    graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
        col=new int[v];
        ar= new set<int>[(int)1e5+1];
        vis=new bool[v];
        for(int i=0;i<v;i++)vis[i]=false;
    }
    void addedge(int a,int b)
    {
        l[a].push_back(b);
        l[b].push_back(a);
    }

    void dfs(int node) {
        //cout<<node<<endl;
        vis[node] = true;
        for (int i:l[node]) {
            //cout<<col[node]<<" "<<col[i]<<" "<<node<<" "<<i<<endl;
            if (!vis[i]) {
                dfs(i);
            }
            if (col[node] != col[i]) {
                ar[col[node]].insert(col[i]);
                ar[col[i]].insert(col[node]);
                //cout << "ehllo" << endl;
                // cout<<node<<" "<<i<<endl;}
                //cout<<node<<" "<<i<<endl;
            }
        }
    }
    void dfshelp(int src)
    {
        //ool vis[v];
        //fill(vis,vis+v,false);
        //for(int i=0;i<v;i++)vis[i]=false;
        //cout<<src<<endl;
        dfs(src);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int i;
    graph g(n+1);
    set<int> pp;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
        pp.insert(g.col[i]);
        //cout<<g.col[i]<<endl;
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<i<<endl;
        //cout<<a<<" "<<b<<endl;

    }
    //cout<<"SDsd";

    g.dfshelp(1);

    int max=0;
    int cool=0;

    for(auto it=pp.begin();it!=pp.end();++it)
    {
        if(g.ar[*it].size()>max)
        {
            cool=*it;
            max=g.ar[*it].size();
        }
        //  cout<<*it<<" "<<max<<endl;
    }

    if(cool==0)
    {
        cool=INT_MAX;
        for(i=1;i<=n;i++)
        {
            if(!g.vis[i])
            {
                cool=min(cool,g.col[i]);
                //break;
            }
        }
    }
    if(cool==INT_MAX)
    {
        cool=g.col[1];
    }
    cout<<cool<<endl;
    return 0;
}


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
class graph
{
public :
    int v;
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
    graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
        col=new int[v];
        ar= new set<int>[(int)1e5+1];
        vis=new bool[v];
        for(int i=0;i<v;i++)vis[i]=false;
    }
    void addedge(int a,int b)
    {
        l[a].push_back(b);
        l[b].push_back(a);
    }

    void dfs(int node) {
        //cout<<node<<endl;
        vis[node] = true;
        for (int i:l[node]) {
            //cout<<col[node]<<" "<<col[i]<<" "<<node<<" "<<i<<endl;
            if (!vis[i]) {
                dfs(i);
            }
            if (col[node] != col[i]) {
                ar[col[node]].insert(col[i]);
                ar[col[i]].insert(col[node]);
                //cout << "ehllo" << endl;
                // cout<<node<<" "<<i<<endl;}
                //cout<<node<<" "<<i<<endl;
            }
        }
    }
    void dfshelp(int src)
    {
        //ool vis[v];
        //fill(vis,vis+v,false);
        //for(int i=0;i<v;i++)vis[i]=false;
        //cout<<src<<endl;
        dfs(src);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int i;
    graph g(n+1);
    set<int> pp;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
        pp.insert(g.col[i]);
        //cout<<g.col[i]<<endl;
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<i<<endl;
        //cout<<a<<" "<<b<<endl;

    }
    //cout<<"SDsd";

    g.dfshelp(1);

    int max=0;
    int cool=INT_MAX;

    for(auto it=pp.begin();it!=pp.end();++it)
    {
        if(g.ar[*it].size()>max)
        {
            cool=*it;
            max=g.ar[*it].size();
        }
        else if(g.ar[*it].size()==max)
        {
            cool=min(cool,*it);
        }
          //cout<<*it<<" "<<max<<" "<<cool<<endl;
    }

    if(cool==INT_MAX)
    {
        cool=INT_MAX;
        for(i=1;i<=n;i++)
        {
            if(!g.vis[i])
            {
                cool=min(cool,g.col[i]);
                //break;
            }
        }
    }
    if(cool==INT_MAX)
    {
        cool=g.col[1];
    }
    cout<<cool<<endl;
    return 0;
}


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
class graph
{
public :
    int v;
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
    graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
        col=new int[v];
        ar= new set<int>[(int)1e5+1];
        vis=new bool[v];
        for(int i=0;i<v;i++)vis[i]=false;
    }
    void addedge(int a,int b)
    {
        l[a].push_back(b);
        l[b].push_back(a);
    }

    void dfs(int node) {
        //cout<<node<<endl;
        vis[node] = true;
        for (int i:l[node]) {
            //cout<<col[node]<<" "<<col[i]<<" "<<node<<" "<<i<<endl;
            if (!vis[i]) {
                dfs(i);
            }
            if (col[node] != col[i]) {
                ar[col[node]].insert(col[i]);
                ar[col[i]].insert(col[node]);
                //cout << "ehllo" << endl;
                // cout<<node<<" "<<i<<endl;}
                //cout<<node<<" "<<i<<endl;
            }
        }
    }
    void dfshelp(int src)
    {
        //ool vis[v];
        //fill(vis,vis+v,false);
        //for(int i=0;i<v;i++)vis[i]=false;
        //cout<<src<<endl;
        dfs(src);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int i;
    graph g(n+1);
    set<int> pp;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
        pp.insert(g.col[i]);
        //cout<<g.col[i]<<endl;
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<i<<endl;
        //cout<<a<<" "<<b<<endl;

    }
    //cout<<"SDsd";

    g.dfshelp(1);

    int max=0;
    int cool=0;

    for(auto it=pp.begin();it!=pp.end();++it)
    {
        if(g.ar[*it].size()>max)
        {
            cool=*it;
            max=g.ar[*it].size();
        }
      //  cout<<*it<<" "<<max<<endl;
    }
    if(cool==0)
    {
        for(i=1;i<=n;i++)
        {
            if(!g.vis[i])
            {
                cool=g.col[i];
                break;
            }
        }
    }
    cout<<cool<<endl;
   return 0;
  }


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
class graph
{
public :
    int v;
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
    graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
        col=new int[v];
        ar= new set<int>[(int)1e5+1];
        vis=new bool[v];
        for(int i=0;i<v;i++)vis[i]=false;
    }
    void addedge(int a,int b)
    {
        l[a].push_back(b);
        l[b].push_back(a);
    }

    void dfs(int node) {
        //cout<<node<<endl;
        vis[node] = true;
        for (int i:l[node]) {
            //cout<<col[node]<<" "<<col[i]<<" "<<node<<" "<<i<<endl;
            if (!vis[i]) {
                dfs(i);
            }
            if (col[node] != col[i]) {
                ar[col[node]].insert(col[i]);
                ar[col[i]].insert(col[node]);
                //cout << "ehllo" << endl;
                // cout<<node<<" "<<i<<endl;}
                //cout<<node<<" "<<i<<endl;
            }
        }
    }
    void dfshelp(int src)
    {
        //ool vis[v];
        //fill(vis,vis+v,false);
        //for(int i=0;i<v;i++)vis[i]=false;
        //cout<<src<<endl;
        dfs(src);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int i;
    graph g(n+1);
    set<int> pp;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
        pp.insert(g.col[i]);
        //cout<<g.col[i]<<endl;
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<i<<endl;
        //cout<<a<<" "<<b<<endl;

    }
    //cout<<"SDsd";

    g.dfshelp(1);

    int max=0;
    int cool=0;

    for(auto it=pp.begin();it!=pp.end();++it)
    {
        if(g.ar[*it].size()>=max)
        {
            cool=min(cool,*it);
            max=g.ar[*it].size();
        }
        //  cout<<*it<<" "<<max<<endl;
    }

    if(cool==0)
    {
        cool=INT_MAX;
        for(i=1;i<=n;i++)
        {
            if(!g.vis[i])
            {
                cool=min(cool,g.col[i]);
                //break;
            }
        }
    }
    if(cool==INT_MAX)
    {
        cool=g.col[1];
    }
    cout<<cool<<endl;
    return 0;
}


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long

using namespace std;

class graph
{
public :
    int v;
    //vector<int> list[(int)1e5+1];
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
    graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
        col=new int[v];
        ar= new set<int>[(int)1e5+1];
        vis=new bool[v];
    }
    void addedge(int a,int b)
    {
        l[a].push_back(b);
        l[b].push_back(a);
    }

    void dfs(int node) {
        //cout<<node<<endl;
        vis[node] = true;
        for (int i:l[node]) {
            //cout<<col[node]<<" "<<col[i]<<" "<<node<<" "<<i<<endl;
            if (!vis[i]) {
                dfs(i);
            }
            if (col[node] != col[i]) {
                ar[col[node]].insert(col[i]);
                ar[col[i]].insert(col[node]);
                //cout << "ehllo" << endl;
                // cout<<node<<" "<<i<<endl;}
                //cout<<node<<" "<<i<<endl;
            }
        }
    }
    void dfshelp(int src)
    {
        //ool vis[v];
        //fill(vis,vis+v,false);
        //for(int i=0;i<v;i++)vis[i]=false;
        //cout<<src<<endl;
        dfs(src);
    }
};

int main()
{
    int n,m;
    cin>>n>>m;
    int i;
    graph g(n+1);
    set<int> pp;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
        pp.insert(g.col[i]);
        //cout<<g.col[i]<<endl;
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<i<<endl;

    }
    //cout<<"SDsd";

    g.dfshelp(1);

    int max=0;
    int col=0;

    for(auto it:pp)
    {
        if(g.ar[it].size()>max)
        {
            col=it;
            max=g.ar[it].size();
        }
        //cout<<it<<" "<<max<<endl;
    }
    cout<<col<<endl;
   return 0;
  }


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
class graph
{
public :
    int v;
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
   graph(int v)
   {
    this->v=v;
    l=new list<int>[v];
    col=new int[v];
    vis=new bool[v];
    ar=new set<int>[(int)1e5+1];
    for(int i=0;i<v;i++)vis[i]=false;
   }
   void addedge(int a,int b)
   {
       l[a].push_back(b);
       l[b].push_back(a);
   }
   void dfshelp(int node)
   {
       vis[node]=true;

       for(int i:l[node])
       {
           if(!vis[i])
           {
               dfshelp(i);
           }
           if(col[node]!=col[i])
           {
               ar[col[node]].insert(col[i]);
               ar[col[i]].insert(col[node]);
           }
       }
   }

   void dfs(int src)
   {
       dfshelp(src);
   }
};

int main()
{

    int n,m;
    cin>>n>>m;
    graph g(n+1);
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<a<<" "<<b<<endl;
    }
    int ma=0;
    int col=INT_MAX;
    for(i=1;i<=n;i++)
    {
       // cout<<col<<endl;
        if(!g.vis[i])
        {
            g.dfs(i);
        }
        if(g.ar[g.col[i]].size()>ma)
        {
            ma=g.ar[g.col[i]].size();
            col=g.col[i];
        }
        else if(g.ar[g.col[i]].size()==ma)
        {
            col=min(col,g.col[i]);
        }

    }
    cout<<col;

    return 0;
}


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
class graph
{
public :
    int v;
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
   graph(int v)
   {
    this->v=v;
    l=new list<int>[v];
    col=new int[v];
    vis=new bool[v];
    ar=new set<int>[(int)1e5+1];
    for(int i=0;i<v;i++)vis[i]=false;
   }
   void addedge(int a,int b)
   {
       l[a].push_back(b);
       l[b].push_back(a);
   }
   void dfshelp(int node)
   {
       vis[node]=true;

       for(int i:l[node])
       {
           if(!vis[i])
           {
               dfshelp(i);
           }
           if(col[node]!=col[i])
           {
               ar[col[node]].insert(col[i]);
               ar[col[i]].insert(col[node]);
           }
       }
   }

   void dfs(int src)
   {
       dfshelp(src);
   }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    graph g(n+1);
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<a<<" "<<b<<endl;
    }
    int ma=0;
    int col=INT_MAX;
    for(i=1;i<=n;i++)
    {
       // cout<<col<<endl;
        if(!g.vis[i])
        {
            g.dfs(i);
        }
        if(g.ar[g.col[i]].size()>ma)
        {
            ma=g.ar[g.col[i]].size();
            col=g.col[i];
        }
        else if(g.ar[g.col[i]].size()==ma)
        {
            col=min(col,g.col[i]);
        }

    }
    cout<<col;

    return 0;
}


#include<iostream>
#include <cmath>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
class graph
{
public :
    int v;
    list<int> *l;
    set<int> *ar;
    int *col;
    bool *vis;
    graph(int v)
    {
        this->v=v;
        l=new list<int>[v];
        col=new int[v];
        ar= new set<int>[(int)1e5+1];
        vis=new bool[v];
        for(int i=0;i<v;i++)vis[i]=false;
    }
    void addedge(int a,int b)
    {
        l[a].push_back(b);
        l[b].push_back(a);
    }

    void dfs(int node) {
        //cout<<node<<endl;
        vis[node] = true;
        for (int i:l[node]) {
            //cout<<col[node]<<" "<<col[i]<<" "<<node<<" "<<i<<endl;
            if (!vis[i]) {
                dfs(i);
            }
            if (col[node] != col[i]) {
                ar[col[node]].insert(col[i]);
                ar[col[i]].insert(col[node]);
                //cout << "ehllo" << endl;
                // cout<<node<<" "<<i<<endl;}
                //cout<<node<<" "<<i<<endl;
            }
        }
    }
    void dfshelp(int src)
    {
        //ool vis[v];
        //fill(vis,vis+v,false);
        //for(int i=0;i<v;i++)vis[i]=false;
        //cout<<src<<endl;
        dfs(src);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int i;
    graph g(n+1);
    set<int> pp;
    for(i=1;i<=n;i++)
    {
        cin>>g.col[i];
        pp.insert(g.col[i]);
        //cout<<g.col[i]<<endl;
    }
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g.addedge(a,b);
        //cout<<i<<endl;
        //cout<<a<<" "<<b<<endl;

    }
    //cout<<"SDsd";

    g.dfshelp(1);

    int max=0;
    int cool=0;

    for(auto it=pp.begin();it!=pp.end();++it)
    {
        if(g.ar[*it].size()>max)
        {
            cool=*it;
            max=g.ar[*it].size();
        }
        //  cout<<*it<<" "<<max<<endl;
    }

    if(cool==0)
    {
        cool=INT_MAX;
        for(i=1;i<=n;i++)
        {
            if(!g.vis[i])
            {
                cool=min(cool,g.col[i]);
                //break;
            }
        }
    }
    if(cool==0)
    {
        cool=g.col[1];
    }
    cout<<cool<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=1e5+3,mod=1e9+7;
typedef long long ll;
int n,m,arr[N],vis[N],x,y;
set<int>ans[N];
vector<int>adj[N];
void dfs(int u)
{
    vis[u]=1;
    for(auto v:adj[u])
    {
        if(!vis[v])
            dfs(v);
        if(arr[v]!=arr[u])
            ans[arr[u]].insert(arr[v]);
    }
}
int main()
{
    Elhabashy
    input();
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    for(int i=0; i<m; i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    for(int i=1; i<=n; i++)
    {
        if(vis[i])
            continue;
        dfs(i);
    }
    int mx=-1,c;
    for(int i=1; i<=1e5; i++)
    {
        if(ans[i].size()>0)
        {
            int x=ans[i].size();
            if(x>mx)
            {
                mx=ans[i].size();
                c=i;
            }
        }
    }
    cout<<c<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=1e5+3,mod=1e9+7;
typedef long long ll;
int n,m,arr[N],ans[N],vis[N],x,y;
vector<int>adj[N];
void dfs(int u){
    vis[u]=1;
    if(ans[arr[u]]==-1)ans[arr[u]]=0;
    for(auto v:adj[u]){
        if(!vis[v])dfs(v);
        if(arr[v]!=arr[u])ans[arr[u]]++;
    }
}
int main()
{
    Elhabashy
    input();
    cin>>n>>m;
    memset(ans,-1,sizeof ans);
    for(int i=1;i<=n;i++)cin>>arr[i];
    for(int i=0;i<m;i++){
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        dfs(i);
    }
    int mx=-1,c;
    for(int i=1;i<=1e5;i++){
        if(ans[i]>mx){
            mx=ans[i];
            c=i;
        }
    }
    cout<<c<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=1e5+3,mod=1e9+7;
typedef long long ll;
int n,m,arr[N],ans[N],vis[N],x,y;
map<pair<int,int>,int>mp;
vector<int>adj[N];
void dfs(int u){
    vis[u]=1;
    if(ans[arr[u]]==-1)ans[arr[u]]=0;
    for(auto v:adj[u]){
        if(!vis[v])dfs(v);
        if(arr[v]!=arr[u])ans[arr[u]]++;
    }
}
int main()
{
    Elhabashy
    input();
    cin>>n>>m;
    memset(ans,-1,sizeof ans);
    for(int i=1;i<=n;i++)cin>>arr[i];
    for(int i=0;i<m;i++){
        cin>>x>>y;
        pair<int,int>p=minmax(x,y);
        if(mp[{p.first,p.second}]==1)continue;
        mp[{p.first,p.second}]=1;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        dfs(i);
    }
    int mx=-1,c;
    for(int i=1;i<=1e5;i++){
        if(ans[i]>mx){
            mx=ans[i];
            c=i;
        }
        if(ans[i]>=0)cout<<i<<" "<<ans[i]<<endl;;
    }
    cout<<c<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=1e5+3,mod=1e9+7;
typedef long long ll;
int n,m,arr[N],vis[N],x,y;
set<int>ans[N];
vector<int>adj[N];
void dfs(int u)
{
    vis[u]=1;
    for(auto v:adj[u])
    {
        if(!vis[v])
            dfs(v);
        if(arr[v]!=arr[u])
            ans[arr[u]].insert(arr[v]);
    }
}
int main()
{
    Elhabashy
    input();
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    for(int i=0; i<m; i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    for(int i=1; i<=n; i++)
    {
        if(vis[i])
            continue;
        dfs(i);
    }
    int mx=-1,c=arr[1];
    sort(arr+1,arr+n+1);
    for(int i=1; i<=n; i++)
    {
        int x=ans[arr[i]].size();
        if(x>mx)
        {
                mx=x;
                c=arr[i];
        }

    }
    cout<<c<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=1e5+3,mod=1e9+7;
typedef long long ll;
int n,m,arr[N],ans[N],vis[N],x,y;
map<pair<int,int>,int>mp;
vector<int>adj[N];
void dfs(int u){
    vis[u]=1;
    if(ans[arr[u]]==-1)ans[arr[u]]=0;
    for(auto v:adj[u]){
        if(!vis[v])dfs(v);
        if(arr[v]!=arr[u])ans[arr[u]]++;
    }
}
int main()
{
    Elhabashy
    input();
    cin>>n>>m;
    memset(ans,-1,sizeof ans);
    for(int i=1;i<=n;i++)cin>>arr[i];
    for(int i=0;i<m;i++){
        cin>>x>>y;
        pair<int,int>p=minmax(x,y);
        if(mp[{p.first,p.second}]==1)continue;
        mp[{p.first,p.second}]=1;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        dfs(i);
    }
    int mx=-1,c;
    for(int i=1;i<=1e5;i++){
        if(ans[i]>mx){
            mx=ans[i];
            c=i;
        }
    }
    cout<<c<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=1e5+3,mod=1e9+7;
typedef long long ll;
int n,m,arr[N],ans[N],vis[N],x,y;
vector<int>adj[N];
void dfs(int u){
    vis[u]=1;
    for(auto v:adj[u]){
        if(!vis[v])dfs(v);
        if(arr[v]!=arr[u])ans[arr[u]]++;
    }
}
int main()
{
    Elhabashy
    input();
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>arr[i];
    for(int i=0;i<m;i++){
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        dfs(i);
    }
    int mx=-1,c;
    for(int i=1;i<=1e5;i++){
        if(ans[i]>mx){
            mx=ans[i];
            c=i;
        }
    }
    cout<<c<<endl;

}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N];
vi G[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        cin >> C[i];

    while (m--) {
        int u, v;
        cin >> u >> v;
        adde(G, C[u], C[v]);
    }

    int res = 0;
    int ans = 1;
    for (int i = 1; i < N; i++) {
        int c = 0;
        for (auto k : G[i]) {
            if (k != i)
                c++;
        }
        if (c > res) {
            res = c;
            ans = i;
        }
    }

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N], cnt[N];
bool exist[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        cin >> C[i], exist[C[i]] = 1;

    int ans = C[1];
    int res = 0;

    while (m--) {
        int u, v;
        cin >> u >> v;
        if (C[u] != C[v]) {
            cnt[C[u]]++;
            cnt[C[v]]++;
        }
    }

    for (int i = 1; i < N; i++) {
        if (!exist[i])
            continue;
        if (cnt[i] > res) {
            res = cnt[i];
            ans = i;
        } else if (cnt[i] == res) {
            ans = min(ans, i);
        }
    }

    for (int i = 1; i < N; i++)
        if (exist[i])
            if (cnt[i] == res) {
                ans = i;
                break;
            }

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N], cnt[N];
bool exist[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        cin >> C[i], exist[C[i]] = 1;

    int ans = C[1];
    int res = 0;

    while (m--) {
        int u, v;
        cin >> u >> v;
        if (C[u] == C[v]) {
            cnt[C[u]]++;
            cnt[C[v]]++;
        }
    }

    for (int i = 1; i < N; i++) {
        if (!exist[i])
            continue;
        if (cnt[i] > res) {
            res = cnt[i];
            ans = i;
        } else if (cnt[i] == res) {
            ans = min(ans, i);
        }
    }

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N];
vi G[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;
    map<int, bool> exist;

    for (int i = 1; i <= n; i++)
        cin >> C[i], exist[C[i]] = 1;

    int ans, temp = 0, same = 0;
    int res = -1000000;

    while (m--) {
        int u, v;
        cin >> u >> v;
        adde(G, C[u], C[v]);
    }

    for (int i = 1; i < N; i++) {
        if (!exist[i])
            continue;

        int c = 0, t = 0;

        for (auto k : G[i]) {
            if (k != i)
                c++;
            else
                t++;
        }

        if (c > res) {
            res = c;
            ans = i;
            same = t;
        } else if (c == res && t < same) {
            same = t;
            ans = i;
        }

        if ((int)G[i].sz == 0)
            temp = i;
    }

    if (res == 0 && temp)
        ans = temp;

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N], cnt[N];
bool exist[N];
map<int, bool> M[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        cin >> C[i], exist[C[i]] = 1;

    int ans = C[1];
    int res = 0;

    while (m--) {
        int u, v;
        cin >> u >> v;
        if (C[u] != C[v]) {
            if (M[u][v])
                continue;
            M[u][v] = M[v][u] = 1;
            cnt[C[u]]++;
            cnt[C[v]]++;
        }
    }

    for (int i = 1; i < N; i++) {
        if (!exist[i])
            continue;
        if (cnt[i] > res) {
            res = cnt[i];
            ans = i;
        } else if (cnt[i] == res) {
            ans = min(ans, i);
        }
    }

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N];
vi G[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;
    map<int, int> M;

    for (int i = 1; i <= n; i++)
        cin >> C[i], M[C[i]] = 1;

    int ans;
    int res = -1000000;

    while (m--) {
        int u, v;
        cin >> u >> v;

        if (C[u] == C[v]) {
            M[C[u]]--;
            M[C[v]]--;
        }
    }

    for (auto i = M.B; i != M.E; i++) {
        if (i->S > res) {
            res = i->S;
            ans = i->F;
        }
    }

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N];
vi G[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;
    map<int, bool> is;

    for (int i = 1; i <= n; i++)
        cin >> C[i], is[C[i]] = 1;

    while (m--) {
        int u, v;
        cin >> u >> v;
        adde(G, C[u], C[v]);
    }

    int res = -1;
    int ans;

    for (int i = 1; i < N; i++) {
        if (!is[i])
            continue;
        int c = 0;
        if ((int)G[i].sz == 0)
            c = 1;
        else
            for (auto k : G[i]) {
                if (k != i)
                    c++;
            }
        if (c > res) {
            res = c;
            ans = i;
        }
    }

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N];
vi G[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;
    map<int, bool> exist;

    for (int i = 1; i <= n; i++)
        cin >> C[i], exist[C[i]] = 1;

    int ans, temp = 0;
    int res = -1000000;

    while (m--) {
        int u, v;
        cin >> u >> v;
        adde(G, C[u], C[v]);
    }

    for (int i = 1; i < N; i++) {
        if (!exist[i])
            continue;

        int c = 0;

        for (auto k : G[i]) {
            if (k != i)
                c++;
        }

        if (c > res) {
            res = c;
            ans = i;
        }

        if ((int)G[i].sz == 0)
            temp = i;
    }

    if (res == 0 && temp)
        ans = temp;

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N];
vi G[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;
    map<int, bool> exist;

    for (int i = 1; i <= n; i++)
        cin >> C[i], exist[C[i]] = 1;

    int ans = 100000000;
    int res = -1000000;

    while (m--) {
        int u, v;
        cin >> u >> v;
        adde(G, C[u], C[v]);
    }

    for (int i = 1; i < N; i++) {
        if (!exist[i])
            continue;

        int c = 0;

        for (auto k : G[i])
            if (k != i)
                c++;

        if (c > res) {
            res = c;
            ans = i;
        } else if (c == res) {
            ans = min(i, ans);
        }
    }

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N];
vi G[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;
    map<int, int> M;

    for (int i = 1; i <= n; i++)
        cin >> C[i], M[C[i]] = 1;

    int ans;
    int res = -1000000;

    while (m--) {
        int u, v;
        cin >> u >> v;

        if (C[u] == C[v]) {
            M[C[u]]--;
            M[C[v]]--;
        } else {
            M[C[u]]++;
            M[C[v]]++;
        }
    }

    for (auto i = M.B; i != M.E; i++) {
        if (i->S > res) {
            res = i->S;
            ans = i->F;
        }
    }

    cout << ans;

    return 0;
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int C[N];
vi G[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);

    int n, m;
    cin >> n >> m;
    map<int, bool> exist;

    for (int i = 1; i <= n; i++)
        cin >> C[i], exist[C[i]] = 1;

    int ans = C[1];
    int res = 0;

    while (m--) {
        int u, v;
        cin >> u >> v;
        adde(G, C[u], C[v]);
    }

    for (int i = 1; i < N; i++) {
        if (!exist[i])
            continue;

        int c = 0;

        for (auto k : G[i])
            if (k != i)
                c++;

        if (c > res) {
            res = c;
            ans = i;
        } else if (c == res) {
            ans = min(i, ans);
        }
    }

    cout << ans;

    return 0;
}