/// ///////////////////////  BISMILLAH   /////////////////////////////////

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main ()
{
              long n,m,h,k,tot=0,low;
              cin>> n>> m;
            long d[n+1]; vector<long> z; vector<long>:: iterator it;

            for(int i=1;i<=n;i++)
                cin>> k, z.push_back(k) , d[i]=k;

                sort(z.begin(),z.end());
                it=unique(z.begin(),z.end());
                   z.resize(distance(z.begin(),it));
                vector<long> x[*(z.end())+1];

                   while(m--)
                   {
                        cin>> h>> k;
                        x[d[h]].push_back(d[k]),
                        x[d[k]].push_back(d[h]);
                   }
                        for(int i=0;i<z.size();i++)
                        {
                             h=false;
                             vector<long>& v= x[z[i]];
                             sort(v.begin(),v.end());
                             it= unique(v.begin(),v.end());
                             v.resize(distance(v.begin(),it));
                             if(find(v.begin(),v.end(),z[i])!=v.end())
                                h=true;
                             if(v.size()-h>tot) tot=v.size()-h,low=z[i];
                        }

                            cout<< low;

              return 0;
}


/// ///////////////////////  BISMILLAH   /////////////////////////////////

#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
#define MAX 3001
#define pb push_back
#define sz size()

int main ()
{
        long n,m,h,k,tot=0,low=100001;
          scanf("%ld%ld",&n,&m); long d[n+1];
          vector<long> c[100001],v[n+1],z;

             for(int i=1;i<=n;i++)
             {
                  scanf("%ld",&k); z.pb(k);
                 c[k].pb(i); d[i]=k;
             }
                  while(m--)
                  {
                        scanf("%ld%ld",&h,&k);
                        v[h].pb(k), v[k].pb(h);
                  }
                      for(long j=0;j<z.sz;j++)
                      {
                           long i=z[j];

                                 set<long> s;
                                 for(long l=0;l<c[i].sz;l++)
                                 {
                                       h=c[i][l];
                                       for(k=0;k<v[h].sz;k++)
                                          s.insert(d[v[h][k]]);
                                 }

                                     if(find(s.begin(),s.end(),i)!=s.end())
                                          s.erase(i);

                                         if(s.sz>tot)
                                            tot=s.sz, low=i;
                                         else if(s.sz== tot && i<low)
                                            low=i;
                      }

                              printf("%ld",low);

              return 0;
}


/*
 * ━━━━━━神兽出没━━━━━━
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛      Code is far away from bug with the animal's protecting
 * 　　　　┃　　　┃          神兽保佑,代码无bug
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣━┓
 * 　　　　┃　　　　　　　┏━┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 *
 *
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <iostream>
#include <math.h>
#include <ctime>
#include <map>
#include <stack>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a));
#define per(i,j,k) for(int i=j;i<=k;i++)
#define rep(i,j,k) for(int i=k;i>=j;i--)
#define rush() int t; scanf("%d",&t); while(t--)
#define INF 0x3f3f3f3f
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
int dir[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
const int maxn = 100205;
const double pi = acos(-1.0);
const int modn = 1000000007;
int main(){
	//freopen("D:\\1input.txt","r",stdin);
	//clock_t start,finish;
	//start = clock();
	int n,m;
	scanf("%d%d",&n,&m);
	vector<int> s[maxn];
	int col[maxn];
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
	}
	int res = INF;
	int vis[maxn];
	for(int i=1;i<=m;i++){
		int u,v;

		scanf("%d%d",&u,&v);
		vis[u] = vis[v] = 1;
		if(col[u] != col[v]){
			s[col[u]].push_back(v);
			s[col[v]].push_back(u);

			if(s[col[u]].size() > s[col[v]].size()){
				res = col[u];
			}
			else if(s[col[u]].size() == s[col[v]].size()){
				res = (col[u]>col[v]?col[v]:col[u]);
			}
		}
	}
	int minn = INF;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			minn = min(minn,col[i]);
		}
	}
	printf("%d\n",min(res,minn));
	//	finish = clock();
	//	cout << finish-start   << "/" << CLOCKS_PER_SEC  << " (s) "<< endl;
}


/*
 * ━━━━━━神兽出没━━━━━━
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛      Code is far away from bug with the animal's protecting
 * 　　　　┃　　　┃          神兽保佑,代码无bug
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣━┓
 * 　　　　┃　　　　　　　┏━┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 *
 *
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <iostream>
#include <math.h>
#include <ctime>
#include <map>
#include <stack>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a));
#define per(i,j,k) for(int i=j;i<=k;i++)
#define rep(i,j,k) for(int i=k;i>=j;i--)
#define rush() int t; scanf("%d",&t); while(t--)
#define INF 0x3f3f3f3f
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
int dir[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
const int maxn = 100205;
const double pi = acos(-1.0);
const int modn = 1000000007;
int main(){
	//freopen("D:\\1input.txt","r",stdin);
	//clock_t start,finish;
	//start = clock();
	int n,m;
	scanf("%d%d",&n,&m);
	vector<int> s[maxn];
	int col[maxn];
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
	}
	int res = INF;
	int vis[maxn];
	for(int i=1;i<=m;i++){
		int u,v;

		scanf("%d%d",&u,&v);
		vis[u] = vis[v] = 1;
		if(col[u] != col[v]){
			s[col[u]].push_back(v);
			s[col[v]].push_back(u);

			if(s[col[u]].size() > s[col[v]].size()){
				res = col[u];
			}
			if(s[col[v]].size() > s[col[u]].size()){
				res = col[v];
			}
			else if(s[col[u]].size() == s[col[v]].size()){
				res = (col[u]>col[v]?col[v]:col[u]);
			}
		}
	}
	int minn = INF;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			minn = min(minn,col[i]);
		}
	}
	printf("%d\n",min(res,minn));
	//	finish = clock();
	//	cout << finish-start   << "/" << CLOCKS_PER_SEC  << " (s) "<< endl;
}


/*
 * ━━━━━━神兽出没━━━━━━
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛      Code is far away from bug with the animal's protecting
 * 　　　　┃　　　┃          神兽保佑,代码无bug
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣━┓
 * 　　　　┃　　　　　　　┏━┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 *
 *
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <iostream>
#include <math.h>
#include <ctime>
#include <map>
#include <stack>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a));
#define per(i,j,k) for(int i=j;i<=k;i++)
#define rep(i,j,k) for(int i=k;i>=j;i--)
#define rush() int t; scanf("%d",&t); while(t--)
#define INF 0x3f3f3f3f
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
int dir[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
const int maxn = 100205;
const double pi = acos(-1.0);
const int modn = 1000000007;
int main(){
	//freopen("D:\\1input.txt","r",stdin);
	//clock_t start,finish;
	//start = clock();
	int n,m;
	scanf("%d%d",&n,&m);
	vector<int> s[maxn];
	int col[maxn];
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
	}
	ll res = 0;
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if(col[u] != col[v]){
			s[col[u]].push_back(v);
			s[col[v]].push_back(u);

			if(s[col[u]].size() > s[col[v]].size()){
				res = col[u];
			}
			else if(s[col[u]].size() == s[col[v]].size()){
				res = (col[u]>col[v]?col[v]:col[u]);
			}
		}
	}
	printf("%d\n",res);
	//	finish = clock();
	//	cout << finish-start   << "/" << CLOCKS_PER_SEC  << " (s) "<< endl;
}


/*
 * ━━━━━━神兽出没━━━━━━
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛      Code is far away from bug with the animal's protecting
 * 　　　　┃　　　┃          神兽保佑,代码无bug
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣━┓
 * 　　　　┃　　　　　　　┏━┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 *
 *
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <iostream>
#include <math.h>
#include <ctime>
#include <map>
#include <stack>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a));
#define per(i,j,k) for(int i=j;i<=k;i++)
#define rep(i,j,k) for(int i=k;i>=j;i--)
#define rush() int t; scanf("%d",&t); while(t--)
#define INF 0x3f3f3f3f
#define pb() push_back()
#define mp() make_pair()
using namespace std;
typedef long long ll;
int dir[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
const int maxn = 100205;
const double pi = acos(-1.0);
const int modn = 1000000007;
set<int> st[maxn];
vector<int>g[maxn];
int main(){
	//freopen("D:\\1input.txt","r",stdin);
	//clock_t start,finish;
	//start = clock();

	int col[maxn];
	int n,m;
	scanf("%d%d",&n,&m);
	map<int,int> z;
	int maxcol = -INF;
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
		maxcol = max(maxcol,col[i]);
		z[col[i]] = 1;
	}
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if(col[u] != col[v]){
			st[col[u]].insert(col[v]);
			st[col[v]].insert(col[u]);
		}
	}
	int s = -1;
	int ans = INF;
	for(int i=1;i<=maxcol;i++){
		if(z[i] == 1){
			int sf = st[i].size();
			if(sf > s){
				s = st[i].size();
				ans = i;
			}
			else if(sf == s){
				if(i < ans){
					ans = i;
				}
			}
		}
	}
	printf("%d\n",ans);
	//	finish = clock();
	//	cout << finish-start   << "/" << CLOCKS_PER_SEC  << " (s) "<< endl;
}


/*
 * ━━━━━━神兽出没━━━━━━
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛      Code is far away from bug with the animal's protecting
 * 　　　　┃　　　┃          神兽保佑,代码无bug
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣━┓
 * 　　　　┃　　　　　　　┏━┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 *
 *
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <iostream>
#include <math.h>
#include <ctime>
#include <map>
#include <stack>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a));
#define per(i,j,k) for(int i=j;i<=k;i++)
#define rep(i,j,k) for(int i=k;i>=j;i--)
#define rush() int t; scanf("%d",&t); while(t--)
#define INF 0x3f3f3f3f
#define pb() push_back()
#define mp() make_pair()
using namespace std;
typedef long long ll;
int dir[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
const int maxn = 100205;
const double pi = acos(-1.0);
const int modn = 1000000007;
vector<int>g[maxn];
vector<int>vec[maxn];
int main(){
	//freopen("D:\\1input.txt","r",stdin);
	//clock_t start,finish;
	//start = clock();
	int n,m;
	scanf("%d %d",&n,&m);
	int maxcol = -INF;
	map<int,int> c;
	for(int i=1;i<=n;i++){
		int col;
		scanf("%d",&col);
		c[i] = col;
		vec[col].push_back(i);
		maxcol = max(maxcol,col);
	}
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		if(c[u] != c[v]){
			g[u].push_back(v);
			g[v].push_back(u);
		}
	}
	int ans = 0;
	int knum = 0;
	for(int i=1;i<=maxcol;i++){
		int allv = 0;
		for(int j=0;j<vec[i].size();j++){
			int v = vec[i][j];
			allv += (g[v].size());
		}
		if(allv > knum){
			knum = allv;
			ans = i;
		}
	}
	printf("%d\n",ans);
	//	finish = clock();
	//	cout << finish-start   << "/" << CLOCKS_PER_SEC  << " (s) "<< endl;
}


/*
 * ━━━━━━神兽出没━━━━━━
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛      Code is far away from bug with the animal's protecting
 * 　　　　┃　　　┃          神兽保佑,代码无bug
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣━┓
 * 　　　　┃　　　　　　　┏━┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 *
 *
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <iostream>
#include <math.h>
#include <ctime>
#include <map>
#include <stack>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a));
#define per(i,j,k) for(int i=j;i<=k;i++)
#define rep(i,j,k) for(int i=k;i>=j;i--)
#define rush() int t; scanf("%d",&t); while(t--)
#define INF 0x3f3f3f3f
#define pb() push_back()
#define mp() make_pair()
using namespace std;
typedef long long ll;
int dir[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
const int maxn = 100205;
const double pi = acos(-1.0);
const int modn = 1000000007;
vector<int>g[maxn];
vector<int>vec[maxn];
int main(){
	//freopen("D:\\1input.txt","r",stdin);
	//clock_t start,finish;
	//start = clock();
	int n,m;
	scanf("%d %d",&n,&m);
	int maxcol = -INF;
	map<int,int> c;
	map<int,int> havecol;
	for(int i=1;i<=n;i++){
		int col;
		scanf("%d",&col);
		c[i] = col;
		havecol[col] = i;
		vec[col].push_back(i);
		maxcol = max(maxcol,col);
	}
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		if(c[u] != c[v]){
			g[u].push_back(v);
			g[v].push_back(u);
		}
	}
	int ans = INF;
	int knum = 0;
	for(int i=1;i<=maxcol;i++){
		if(!havecol[i]) continue;
		int allv = 0;
		for(int j=0;j<vec[i].size();j++){
			int v = vec[i][j];
			allv += (g[v].size());
		}
		if(allv > knum){
			knum = allv;
		 	ans = i;
		}
		else if(allv == knum){
			ans = min(ans,i);
		}
	}
	printf("%d\n",ans);
	//	finish = clock();
	//	cout << finish-start   << "/" << CLOCKS_PER_SEC  << " (s) "<< endl;
}


/*
 * ━━━━━━神兽出没━━━━━━
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛      Code is far away from bug with the animal's protecting
 * 　　　　┃　　　┃          神兽保佑,代码无bug
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣━┓
 * 　　　　┃　　　　　　　┏━┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 *
 *
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <iostream>
#include <math.h>
#include <ctime>
#include <map>
#include <stack>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a));
#define per(i,j,k) for(int i=j;i<=k;i++)
#define rep(i,j,k) for(int i=k;i>=j;i--)
#define rush() int t; scanf("%d",&t); while(t--)
#define INF 0x3f3f3f3f
#define pb() push_back()
#define mp() make_pair()
using namespace std;
typedef long long ll;
int dir[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
const int maxn = 100205;
const double pi = acos(-1.0);
const int modn = 1000000007;
vector<int>g[maxn];
int main(){
	//freopen("D:\\1input.txt","r",stdin);
	//clock_t start,finish;
	//start = clock();
	int size[maxn];
	mst(size,0);
	int col[maxn];
	int n,m;
	scanf("%d%d",&n,&m);
	map<int,int> z;
	int maxcol = -INF;
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
		maxcol = max(maxcol,col[i]);
		z[col[i]] = 1;
	}
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if(col[u] != col[v]){
			size[col[u]]++;
			size[col[v]]++;
		}
	}
	int s = -1;
	int ans = INF;
	for(int i=1;i<=maxcol;i++){
		if(z[i] == 1){
			if(size[i] > s){
				s = size[i];
				ans = i;
			}
			else if(size[i] == s){
				if(i < ans){
					ans = i;
				}
			}
		}
	}
	printf("%d\n",ans);
	//	finish = clock();
	//	cout << finish-start   << "/" << CLOCKS_PER_SEC  << " (s) "<< endl;
}


/*
 * ━━━━━━神兽出没━━━━━━
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛      Code is far away from bug with the animal's protecting
 * 　　　　┃　　　┃          神兽保佑,代码无bug
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣━┓
 * 　　　　┃　　　　　　　┏━┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 *
 *
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <iostream>
#include <math.h>
#include <ctime>
#include <map>
#include <stack>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a));
#define per(i,j,k) for(int i=j;i<=k;i++)
#define rep(i,j,k) for(int i=k;i>=j;i--)
#define rush() int t; scanf("%d",&t); while(t--)
#define INF 0x3f3f3f3f
#define pb() push_back()
#define mp() make_pair()
using namespace std;
typedef long long ll;
int dir[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
const int maxn = 100205;
const double pi = acos(-1.0);
const int modn = 1000000007;
vector<int>g[maxn];
vector<int>vec[maxn];
int main(){
	//freopen("D:\\1input.txt","r",stdin);
	//clock_t start,finish;
	//start = clock();
	int n,m;
	scanf("%d %d",&n,&m);
	int maxcol = -INF;
	map<int,int> c;
	map<int,int> havecol;
	for(int i=1;i<=n;i++){
		int col;
		scanf("%d",&col);
		c[i] = col;
		havecol[col] = i;
		vec[col].push_back(i);
		maxcol = max(maxcol,col);
	}
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		if(c[u] != c[v]){
			g[u].push_back(v);
			g[v].push_back(u);
		}
	}
	int ans = 0;
	int knum = 0;
	for(int i=1;i<=maxcol;i++){
		if(!havecol[i]) continue;
		int allv = 0;
		if(g[havecol[i]].size() == 0){
			allv += 1;
		}
		for(int j=0;j<vec[i].size();j++){
			int v = vec[i][j];
			allv += (g[v].size());
		}
		if(allv > knum){
			knum = allv;
			ans = i;
		}
	}
	printf("%d\n",ans);
	//	finish = clock();
	//	cout << finish-start   << "/" << CLOCKS_PER_SEC  << " (s) "<< endl;
}


/*
 * ━━━━━━神兽出没━━━━━━
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　　　　　┃
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛      Code is far away from bug with the animal's protecting
 * 　　　　┃　　　┃          神兽保佑,代码无bug
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣━┓
 * 　　　　┃　　　　　　　┏━┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 *
 *
 */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <iostream>
#include <math.h>
#include <ctime>
#include <map>
#include <stack>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a));
#define per(i,j,k) for(int i=j;i<=k;i++)
#define rep(i,j,k) for(int i=k;i>=j;i--)
#define rush() int t; scanf("%d",&t); while(t--)
#define INF 0x3f3f3f3f
#define pb() push_back()
#define mp() make_pair()
using namespace std;
typedef long long ll;
int dir[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
const int maxn = 100205;
const double pi = acos(-1.0);
const int modn = 1000000007;
vector<int>g[maxn];
int main(){
	//freopen("D:\\1input.txt","r",stdin);
	//clock_t start,finish;
	//start = clock();
	set<int> size[maxn];
	mst(size,0);
	int col[maxn];
	int n,m;
	scanf("%d%d",&n,&m);
	map<int,int> z;
	int maxcol = -INF;
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
		maxcol = max(maxcol,col[i]);
		z[col[i]] = 1;
	}
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if(col[u] != col[v]){
			size[col[u]].insert(col[v]);
			size[col[v]].insert(col[u]);
		}
	}
	int s = -1;
	int ans = INF;
	for(int i=1;i<=maxcol;i++){
		if(z[i] == 1){
			if(size[i].size() > s){
				s = size[i];
				ans = i;
			}
			else if(size[i].size() == s){
				if(i < ans){
					ans = i;
				}
			}
		}
	}
	printf("%d\n",ans);
	//	finish = clock();
	//	cout << finish-start   << "/" << CLOCKS_PER_SEC  << " (s) "<< endl;
}


#include<iostream>
#include<vector>
using namespace std;
const int maxn=222222;
vector<int> g[maxn],gg[maxn];
vector<vector<bool > > g1(maxn);
long long int n,m,c[maxn],max1=0,x,y,qq,max2;
bool used[maxn];
void dfs(int v){
    used[v]=true;
    for(int i=0;i<g[v].size();i++){
        int to=g[v][i];
        if(!g1[c[v]][c[to]] && c[v]!=c[to]){
            gg[c[to]].push_back(c[v]);
            gg[c[v]].push_back(c[to]);
            g1[c[v]][c[to]]=true;
            g1[c[to]][c[v]]=true;
        }
        if(!used[to])dfs(to);
    }
}
void fd(){
    for(int i=1;i<=n;i++)used[i]=false;

    for(int i=1;i<=n;i++)if(!used[i])dfs(i);
}
void fc(){
    max2=0;
    qq=-1;
    for(int i=1;i<=max1;i++){if(max2<gg[i].size()){qq=i;max2=gg[i].size();}}
    //return qq;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){cin>>c[i];if(c[i]>=max1)max1=c[i];}
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    fd();
    fc();
    int max3=111111;
    if(qq!=-1)
    cout<<qq;
    else {
        for(int i=1;i<=n;i++)if(c[i]<max3)max3=c[i];
    cout<<max3;
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
#define pb push_back
vector<int> g[111111];
int color[111111];
int n,m,qq,max1=-111,mm=-111111111,mmi=111111111;
int main(){
    int x,y;
    cin>>n>>m;
    for(int i=1;i<=n;i++){cin>>color[i];if(color[i]>=mm)mm=color[i];if(color[i]<=mmi)mmi=color[i];}
    for(int i=1;i<=m;i++){
            cin>>x>>y;
            g[color[x]].pb(color[y]);
            g[color[y]].pb(color[x]);
            }
    for(int i=mm;i>=mmi;i--){
            vector<int> c(111111,0);
    int d=0;
    int o=0;
            //cout<<endl;
            //cout<<i<<" :  ";
            for(int j=0;j<g[i].size();j++){
                    if(c[g[i][j]]==0){d++;c[g[i][j]]=1;if(g[i][j]==i)o++;}
                    //cout<<g[i][j]<<" ";
                    }
                    if(o>=1)d--;
                    //cout<<d<<endl;
                    if(d>=max1){max1=d;qq=i;}
            }
            cout<<qq;
    //system("pause");
    return 0;
    }


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define pb push_back
const int inf=11111111;
typedef vector<int> vint;
vint h[111111],f(111111,0),q,e,r;
int n,m,x,y,k[111111],max1=-1,max2=-1,min1=999999,t=999999;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>k[i];
        if(k[i]>max2)max2=k[i];
        if(min1>k[i])min1=k[i];
    }
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        if(k[x]!=k[y]){h[k[x]].pb(k[y]);h[k[y]].pb(k[x]);}
}
cout<<endl;
sort(k+1,k+n+1);
    for(int i=1;i<=n;i++){
    int s=0;
    vector<bool> used(max2+1,false);
    for(int j=0;j<h[k[i]].size();j++){
        int to=h[k[i]][j];
        if(!used[to]){
            s++;
            used[to]=true;
        }
    }
    if(s>max1){
        max1=s;
        t=k[i];
        q.pb(k[i]);
    }
    }
    if(max1==-1)cout<<min1;
    else{
        cout<<t;
    }
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define pb push_back
const int inf=11111111;
typedef vector<int> vint;
vint h[111111],f(111111,0),q;
int n,m,x,y,k[111111],max1=-1,max2=-1,min1=999999;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>k[i];
        if(k[i]>max2)max2=k[i];
        if(min1>k[i])min1=k[i];
    }
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        if(k[x]!=k[y]){h[k[x]].pb(k[y]);h[k[y]].pb(k[x]);}
}
    for(int i=max2;i>=1;i--){
    int s=0;
    vector<bool> used(max2+1,false);
    for(int j=0;j<h[k[i]].size();j++){
        int to=h[k[i]][j];
        if(!used[to]){
            s++;
            used[to]=true;
        }
    }
    if(s>=max1 && s!=0){
        max1=s;
        q.pb(k[i]);
    }
    }
    if(max1==-1)cout<<min1;
    else{
    sort(q.begin(),q.end());
    //reverse(q.begin(),q.end());
    cout<<q[0];}
    return 0;
}


#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
set<int> g[111111];
#define pb push_back
int main(){
    int n,m,a[111111],x,y;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        int t=a[x];
        int f=a[y];
        if(t==f)continue;
        g[t].insert(f);
        g[f].insert(t);

    }
    int min1=0;
    int u=*min_element(a+1,a+n+1);
    for(int i=1;i<=111111;i++)
        if(g[i].size()>min1){
            u=i;
            min1=g[i].size();
        }
    cout<<u;
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define pb push_back
const int inf=11111111;
typedef vector<int> vint;
vint h[111111],f(111111,0),q;
int n,m,x,y,k[111111],max1=-1,max2=-1;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>k[i];
		if(k[i]>max2)max2=k[i];
	}
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		if(k[x]!=k[y]){h[k[x]].pb(k[y]);h[k[y]].pb(k[x]);}
}
	for(int i=max2;i>=1;i--){
	int s=0;
	vector<bool> used(max2+1,false);
	for(int j=0;j<h[k[i]].size();j++){
		int to=h[k[i]][j];
		if(!used[to]){
			s++;
			used[to]=true;
		}
	}
	if(s>=max1){
		max1=s;
		q.pb(k[i]);
	}
	f.clear();
	}
	sort(q.begin(),q.end());
	cout<<q[0];
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
const int maxn=111111;
vector<int> g[maxn],gg[maxn];
vector<vector<bool > > g1(maxn);
int n,m,c[maxn],max1=0,x,y,qq,max2;
bool used[maxn];
void dfs(int v){
    used[v]=true;
    for(int i=0;i<g[v].size();i++){
        int to=g[v][i];
        if(!g1[c[v]][c[to]] && c[v]!=c[to]){
            gg[c[to]].push_back(c[v]);
            gg[c[v]].push_back(c[to]);
            g1[c[v]][c[to]]=true;
            g1[c[to]][c[v]]=true;
        }
        if(!used[to])dfs(to);
    }
}
void fd(){
    for(int i=1;i<=n;i++)used[i]=false;

    for(int i=1;i<=n;i++)if(!used[i])dfs(i);
}
void fc(){
    max2=0;
    qq=-1;
    for(int i=1;i<=max1;i++){if(max2<gg[i].size()){qq=i;max2=gg[i].size();}}
    //return qq;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){cin>>c[i];if(c[i]>=max1)max1=c[i];}
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    fd();
    fc();
    cout<<qq;
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
const int maxn=111111;
vector<int> g[maxn],gg[maxn];
vector<vector<bool > > g1(maxn);
int n,m,c[maxn],max1=0,x,y,qq,max2;
bool used[maxn];
void dfs(int v){
	used[v]=true;
	for(int i=0;i<g[v].size();i++){
		int to=g[v][i];
		if(!g1[c[v]][c[to]] && c[v]!=c[to]){
			gg[c[to]].push_back(c[v]);
			gg[c[v]].push_back(c[to]);
			g1[c[v]][c[to]]=true;
			g1[c[to]][c[v]]=true;
		}
		if(!used[to])dfs(to);
	}
}
void fd(){
	for(int i=1;i<=n;i++)used[i]=false;

	for(int i=1;i<=n;i++)if(!used[i])dfs(i);
}
void fc(){
	max2=0;
	qq=-1;
	for(int i=1;i<=max1;i++){if(max2<gg[i].size()){qq=i;max2=gg[i].size();}}
	//return qq;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){cin>>c[i];if(c[i]>=max1)max1=c[i];}
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	fd();
	fc();
	int max3=111111;
	if(qq!=-1)
	cout<<qq;
	else {
		for(int i=1;i<=n;i++)if(c[i]<max3)max3=c[i];
	cout<<max3;
	}
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
const int maxn=111111;
vector<int> g[maxn],gg[maxn];
vector<vector<bool > > g1(maxn);
long long int n,m,c[maxn],max1=0,x,y,qq,max2;
bool used[maxn];
void dfs(int v){
    used[v]=true;
    for(int i=0;i<g[v].size();i++){
        int to=g[v][i];
        if(!g1[c[v]][c[to]] && c[v]!=c[to]){
            gg[c[to]].push_back(c[v]);
            gg[c[v]].push_back(c[to]);
            g1[c[v]][c[to]]=true;
            g1[c[to]][c[v]]=true;
        }
        if(!used[to])dfs(to);
    }
}
void fd(){
    for(int i=1;i<=n;i++)used[i]=false;

    for(int i=1;i<=n;i++)if(!used[i])dfs(i);
}
void fc(){
    max2=0;
    qq=-1;
    for(int i=1;i<=max1;i++){if(max2<gg[i].size()){qq=i;max2=gg[i].size();}}
    //return qq;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){cin>>c[i];if(c[i]>=max1)max1=c[i];}
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    fd();
    fc();
    int max3=111111;
    if(qq!=-1)
    cout<<qq;
    else {
        for(int i=1;i<=n;i++)if(c[i]<max3)max3=c[i];
    cout<<max3;
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
#define pb push_back
vector<int> g[111111];
int color[111111];
int n,m,qq,max1=-111,mmmm=111111111;
int main(){
    int x,y;
    cin>>n>>m;
    for(int i=1;i<=n;i++){cin>>color[i];}
    for(int i=1;i<=m;i++){
            cin>>x>>y;
            g[color[x]].pb(color[y]);
            g[color[y]].pb(color[x]);
            }
            sort(color+1,color+n+1);
            reverse(color+1,color+n+1);
    for(int i=1;i<=n;i++){
            int u=color[i];
            vector<int> c(111111,0);
    int d=0;
    int o=0;
            //cout<<endl;
           // cout<<u<<" :  ";
            for(int j=0;j<g[u].size();j++){
                    if(c[g[u][j]]==0 && g[u][j]!=u){d++;c[g[u][j]]=1;}
                    //cout<<g[u][j]<<" ";
                    }
                    //if(o>=1)d-=o;
                    //cout<<d<<endl;
                    if(d>=max1 && mmmm>=u){max1=d;qq=u;mmmm=u;}
            }
            cout<<qq;
   // system("pause");
    return 0;
    }


#include<iostream>
#include<vector>
using namespace std;
const int maxn=111111*4;
vector<int> g[maxn],gg[maxn];
vector<vector<bool > > g1(maxn);
long long int n,m,c[maxn],max1=0,x,y,qq,max2;
bool used[maxn];
void dfs(int v){
    used[v]=true;
    for(int i=0;i<g[v].size();i++){
        int to=g[v][i];
        if(!g1[c[v]][c[to]] && c[v]!=c[to]){
            gg[c[to]].push_back(c[v]);
            gg[c[v]].push_back(c[to]);
            g1[c[v]][c[to]]=true;
            g1[c[to]][c[v]]=true;
        }
        if(!used[to])dfs(to);
    }
}
void fd(){
    for(int i=1;i<=n;i++)used[i]=false;

    for(int i=1;i<=n;i++)if(!used[i])dfs(i);
}
void fc(){
    max2=0;
    qq=-1;
    for(int i=1;i<=max1;i++){if(max2<gg[i].size()){qq=i;max2=gg[i].size();}}
    //return qq;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){cin>>c[i];if(c[i]>=max1)max1=c[i];}
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    fd();
    fc();
    int max3=111111;
    if(qq!=-1)
    cout<<qq;
    else {
        for(int i=1;i<=n;i++)if(c[i]<max3)max3=c[i];
    cout<<max3;
    }
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define pb push_back
const int inf=11111111;
typedef vector<int> vint;
vint h[111111],f(111111,0),q;
int n,m,x,y,k[111111],max1=-1,max2=-1;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>k[i];
        if(k[i]>max2)max2=k[i];
    }
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        if(k[x]!=k[y]){h[k[x]].pb(k[y]);h[k[y]].pb(k[x]);}
}
    for(int i=max2;i>=1;i--){
    int s=0;
    vector<bool> used(max2+1,false);
    for(int j=0;j<h[k[i]].size();j++){
        int to=h[k[i]][j];
        if(!used[to]){
            s++;
            used[to]=true;
        }
    }
    if(s>=max1 && s!=0){
        max1=s;
        q.pb(k[i]);
    }
    }
    sort(q.begin(),q.end());
    //reverse(q.begin(),q.end());
    cout<<q[0];
    return 0;
}


#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
#define pb push_back
vector<int> g[111111];
int color[111111];
int n,m,qq,max1=-111,mm=-111111111,mmi=111111111;
int main(){
    int x,y;
    cin>>n>>m;
    for(int i=1;i<=n;i++){cin>>color[i];if(color[i]>=mm)mm=color[i];if(color[i]<=mmi)mmi=color[i];}
    for(int i=1;i<=m;i++){
            cin>>x>>y;
            g[color[x]].pb(color[y]);
            g[color[y]].pb(color[x]);
            }
    for(int i=mm;i>=mmi;i--){
            vector<int> c(111111,0);
    int d=0;
            //cout<<endl;
            //cout<<i<<" :  ";
            for(int j=0;j<g[i].size();j++){
                    if(c[g[i][j]]==0){d++;c[g[i][j]]=1;}
                    //cout<<g[i][j]<<" ";
                    }
                    if(d>=max1){max1=d;qq=i;}
            }
            cout<<qq;
    //system("pause");
    return 0;
    }


#include<stdio.h>
#include<set>
#include<vector>
#define MAX 100200
#include<string.h>
#include<algorithm>
using namespace std;
vector<int> ans;
set<int> ss;
set<int> st[MAX];
int cnt[MAX];
int c[MAX];
main(){
	//freopen("test.inp","r",stdin);
	int N,M;
	scanf("%d %d",&N,&M);
	for(int i=1;i<=N;i++){
	  scanf("%d",&c[i]);
	  if(ss.find(c[i])==ss.end()){
	  	ss.insert(c[i]);
	  	ans.push_back(c[i]);
	  }
     }
	memset(cnt,0,sizeof cnt);
	for(int i=1;i<=M;i++){
		int u,v;
		scanf("%d %d",&u,&v);

		if(c[u]==c[v]) continue;
		if(st[c[u]].find(c[v])==st[c[u]].end()){
			cnt[c[u]]++;
			st[c[u]].insert(c[v]);
		}
		if(st[c[v]].find(c[u])==st[c[v]].end()){
			cnt[c[v]]++;
			st[c[v]].insert(c[u]);
		}
	}
	sort(ans.begin(),ans.end());
	int mmax=cnt[ans[0]];
	int re=ans[0];
	for(int i=1;i<ans.size();i++)
		if(cnt[ans[i]]>mmax){
			mmax=cnt[ans[i]];
			re=ans[i];
		}
	printf("%d",re);
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(typeof (n) i = 0; i < (n); ++i)
int color[(int)1e5];
set<int> s[(int)1e5];
int N, M, a, b;
int main(){
    ios::sync_with_stdio(0);
    cin >> N >> M;
    REP(i, N) cin >> color[i];
    REP(i, M){
        cin >> a >> b;
        if (color[a - 1] != color[ b- 1]){
            s[color[a - 1]].insert(color[b - 1]);
            s[color[b - 1]].insert(color[a - 1]);
        }
    }
    int res = 0, index;
    REP(i, N){
        if ((int)s[i].size() > res){
            res = s[i].size();
            index = i;
        }
    }
    cout << color[index];
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(typeof (n) i = 0; i < (n); ++i)
int color[(int)1e5];
set<int> s[(int)1e5];
int N, M, a, b;
int main(){
    ios::sync_with_stdio(0);
    cin >> N >> M;
    REP(i, N) cin >> color[i];
    REP(i, M){
        cin >> a >> b;
        if (color[a - 1] != color[ b- 1]){
            s[color[a - 1]].insert(color[b - 1]);
            s[color[b - 1]].insert(color[a - 1]);
        }
    }
    int res = 0, t;
    REP(i, N) res = min(res,color[i]);
    REP(i, N) if((int)s[i].size() > t) res = i, t = s[i].size();
    cout << res;
}


#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
vector <int> a[100100],color[100100];
int c[100100];
int dfs(int x)
{
    bool check[100100];
    int ans=0;
    memset(check,false,sizeof(check));
        check[x]=true;
    for(int i=0;i<color[x].size();i++)
    {
        int tmp=color[x][i];
        for(int j=0;j<a[tmp].size();j++)
        {
            if(check[c[a[tmp][j]]]!=true)
                {
                //printf("%d %d\n",x,c[a[tmp][j]]);
                    ans++;
                    check[c[a[tmp][j]]]=true;
                }
        }
    }
    return ans;
}
int main()
{
    int n,i,m,x,y,imax=-1,save=999999999;
    bool ch[100010];
    //freopen("test.inp","r",stdin);
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        color[x].push_back(i);
        c[i]=x;
    }
    while(m--)
    {
        scanf("%d %d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(i=1;i<=n;i++)
    {
        if(ch[c[i]]!=true)
        {
        ch[c[i]]=true;
        int tmp=dfs(c[i]);
        //printf("%d\n",tmp);
        if(imax==tmp)
        {
            if(c[i]<save)
            save=c[i];
        }
        else if(imax<tmp)
        {
            imax=tmp;
            save=c[i];
        }
        }
    }
    printf("%d",save);
}


#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
vector <int> a[100100],color[100100];
int c[100100];
int dfs(int x)
{
    bool check[100100];
    int ans=0;
    memset(check,false,sizeof(check));
        check[x]=true;
    for(int i=0;i<color[x].size();i++)
    {
        int tmp=color[x][i];
        for(int j=0;j<a[tmp].size();j++)
        {
            if(check[c[a[tmp][j]]]!=true)
            if(c[tmp]!=c[a[tmp][j]])
                {
                //printf("%d %d\n",x,c[a[tmp][j]]);
                    ans++;
                    check[c[a[tmp][j]]]=true;
                }
        }
    }
    return ans;
}
int main()
{
    int n,i,m,x,y,imax=-1,save=999999999;
    bool ch[100010];
    //freopen("test.inp","r",stdin);
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        color[x].push_back(i);
        c[i]=x;
    }
    while(m--)
    {
        scanf("%d %d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(i=1;i<=n;i++)
    {
        if(ch[c[i]]!=true)
        {
        ch[c[i]]=true;
        int tmp=dfs(c[i]);
        //printf("%d\n",tmp);
        if(imax==tmp)
        {
            if(c[i]<=save)
            save=c[i];
            //printf("2222%d\n",c[i]);
        }
        else if(imax<tmp)
        {
            imax=tmp;
            save=c[i];
            //printf("1111%d\n",c[i]);
        }
        }
    }
    printf("%d",save);
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int n,m;
vector<vector<int> > E;
vector<vector<int> > C;

int main(){
    //freopen("input.inp","r",stdin);
    scanf("%d%d",&n,&m);
    int c;
    int x[n+1];
    E.resize(n);
    C.resize(100001);
    for(int i=0;i<n;i++){
        scanf("%d",x+i);
        C[x[i]].push_back(i);
    }
    int a,b;
    while(m--){
        scanf("%d%d",&a,&b);
        a--;b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    int imax=1,amax=-1;
    for(int i=1;i<=100000;i++)if(!C[i].empty()){
        set<int> s;
        for(unsigned j=0;j<C[i].size();j++)
            for(unsigned k=0;k<E[C[i][j]].size();k++){
                s.insert(x[E[C[i][j]][k]]);
                //printf("%d\n",E[C[i][j]][k]);
            }
        int tmp=s.size();
        if(tmp>amax){
            amax=tmp;
            imax=i;
        }
    }
    printf("%d",imax);
}


#include<stdio.h>
#include<set>
#include<vector>
#define MAX 100200
#include<string.h>
#include<algorithm>
using namespace std;
vector<int> ans;
set<int> ss;
set<int> st[MAX];
int cnt[MAX];
int c[MAX];
main(){
    //freopen("test.inp","r",stdin)
    int N,M;
    scanf("%d %d",&N,&M);
    for(int i=1;i<=N;i++)
      scanf("%d",&c[i]);
    memset(cnt,0,sizeof cnt);
    for(int i=1;i<=M;i++){
        int u,v;
        scanf("%d %d",&u,&v);
        if(ss.find(c[u])==ss.end()) {
            ss.insert(c[u]);
            ans.push_back(c[u]);
        }
        if(ss.find(c[v])==ss.end()){
            ss.insert(c[v]);
            ans.push_back(c[v]);
        }
        if(c[u]==c[v]) continue;
        if(st[c[u]].find(c[v])==st[c[u]].end()){
            cnt[c[u]]++;
            st[c[u]].insert(c[v]);
        }
        if(st[c[v]].find(c[u])==st[c[v]].end()){
            cnt[c[v]]++;
            st[c[v]].insert(c[u]);
        }
    }
    sort(ans.begin(),ans.end());
    int mmax=cnt[ans[0]];
    int re=ans[0];
    for(int i=1;i<ans.size();i++)
        if(cnt[ans[i]]>mmax){
            mmax=cnt[ans[i]];
            re=ans[i];
        }
    printf("%d",re);
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int n,m;
vector<vector<int> > E;
vector<vector<int> > C;

int main(){
    //freopen("input.inp","r",stdin);
    scanf("%d%d",&n,&m);
    int c;
    int x[n+1];
    E.resize(n);
    C.resize(100001);
    for(int i=0;i<n;i++){
        scanf("%d",x+i);
        C[x[i]].push_back(i);
    }
    int a,b;
    while(m--){
        scanf("%d%d",&a,&b);
        a--;b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    int imax=1,amax=0;
    for(int i=1;i<=100000;i++)if(!C[i].empty()
    ){
        set<int> s;
        for(unsigned j=0;j<C[i].size();j++)
            for(unsigned k=0;k<E[C[i][j]].size();k++){
                s.insert(x[E[C[i][j]][k]]);
                //printf("%d\n",E[C[i][j]][k]);
            }
        if(s.size()>amax){
            amax=s.size();
            imax=i;
        }
    }
    printf("%d",imax);
}


#include<bits/stdc++.h>
using namespace std;
#define N (int ) 1e5+5
int n,m,d[N];
int a[N];
int res=0,ans=0;
map<int,int> mp[N];
int main(){
    //freopen("era.cpp","r",stdin);
    cin>>n>>m;
    int color=0;
    for(int i=1;i<=n;++i)  scanf("%d",&d[i]),color=max(color,d[i]);
    while(m--){
        int p,q;
        scanf("%d%d",&p,&q);
        int u=d[p],v=d[q];
        if(u!=v && !mp[u].count(v)){
            mp[u][v]=1;
            a[u]++;
            a[v]++;
            mp[v][u]=1;
        }
    }
    for(int i=1;i<=color;++i)
    if(res<a[i]){
        res=a[i];
        ans=i;
    }
    cout<<ans;
}


#include<stdio.h>
#include<set>
#include<vector>
#define MAX 100200
#include<string.h>
#include<algorithm>
using namespace std;
vector<int> ans;
set<int> ss;
set<int> st[MAX];
int cnt[MAX];
int c[MAX];
main(){
    //freopen("test.inp","r",stdin);
    int N,M;
    scanf("%d %d",&N,&M);
    for(int i=1;i<=N;i++)
      scanf("%d",&c[i]);
    memset(cnt,0,sizeof cnt);
    for(int i=1;i<=M;i++){
        int u,v;
        scanf("%d %d",&u,&v);
        if(ss.find(c[u])==ss.end()) {
            ss.insert(c[u]);
            ans.push_back(c[u]);
        }
        if(st[c[u]].find(c[v])==st[c[u]].end()){
            cnt[c[u]]++;
            st[c[u]].insert(c[v]);
        }
        if(ss.find(c[v])==ss.end()){
            ss.insert(c[v]);
            ans.push_back(c[v]);
        }
        if(st[c[v]].find(c[u])==st[c[v]].end()){
            cnt[c[v]]++;
            st[c[v]].insert(c[u]);
        }
    }
    sort(ans.begin(),ans.end());
    int mmax=cnt[ans[0]];
    int re=ans[0];
    for(int i=1;i<ans.size();i++)
        if(cnt[ans[i]]>mmax){
            mmax=cnt[ans[i]];
            re=ans[i];
        }
    printf("%d",re);
}


#include<bits/stdc++.h>
using namespace std;
#define N (int ) 1e5+5
int n,m,d[N];
int a[N]={1};
int res=-1,ans=0;
map<int,int> mp[N];
map<int,int> cunt;
int cnt=0;
vector<int> task;
int main(){
   // freopen("Dothi.cpp","r",stdin);
    cin>>n>>m;
    int color=0;
    for(int i=1;i<=n;++i)  {
        scanf("%d",&d[i]),color=max(color,d[i]);
        if(!cunt.count(d[i]))  cunt[d[i]]=++cnt,task.push_back(d[i]);
    }
    while(m--){
        int p,q;
        scanf("%d%d",&p,&q);
        int u=d[p],v=d[q];
        if(u!=v && !mp[u].count(v)){
            mp[u][v]=1;
            a[u]++;
            a[v]++;
            mp[v][u]=1;
        }
    }
    for(int i=0;i<task.size();++i)
    if(res<a[task[i]]){
        res=a[task[i]];
        ans=task[i];
    }
    else if(res==a[task[i]] &&ans>task[i]){
        res=a[task[i]];
        ans=task[i];
    }
    cout<<ans;
   //for(int i=0;i<task.size();++i)
       // cout<<a[task[i]]<<"  belong to "<<task[i]<<endl;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#define nmax 100000
const int INF=(int)1e9+7;

using namespace std;
typedef set<int> si;

int n, u, v, m, temp;
set<int> color;
set<int> adjlist[nmax];
int c[nmax], p, ans;

int main() {
    //freopen("color.inp","r",stdin);
    scanf("%d %d",&n,&m);
    temp=-INF;
    for (int i=0;i<n;i++) {
        scanf("%d",&c[i]);
        if (c[i]>temp) temp=c[i];
        color.insert(c[i]);
    }
    for (int i=0;i<m;i++) {
        cin>>u>>v;
        u--;
        v--;
        if (c[u]!=c[v]) {
            adjlist[c[u]].insert(c[v]);
            adjlist[c[v]].insert(c[u]);
        }
    }
    p=-INF;
    set<int>::iterator it;
    for (it=color.begin();it!=color.end();++it) {
        int v=adjlist[*it].size();
        if (v>p) {
            p=v;
            ans=(*it);
        }
    }
    printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
#define N (int ) 1e5+5
int n,m,d[N];
int a[N]={1};
int res=-1,ans=0;
map<int,int> mp[N];
map<int,int> cunt;
int cnt=0;
vector<int> task;
int main(){
    //freopen("Dothi.cpp","r",stdin);
    cin>>n>>m;
    int color=0;
    for(int i=1;i<=n;++i)  {
        scanf("%d",&d[i]),color=max(color,d[i]);
        if(!cunt.count(d[i]))  cunt[d[i]]=++cnt,task.push_back(d[i]);
    }
    while(m--){
        int p,q;
        scanf("%d%d",&p,&q);
        int u=d[p],v=d[q];

        if(u!=v){
            if(!mp[u].count(q)){
                mp[u][q]=1;
                a[u]++;
            }
            if(!mp[v].count(p)){
                mp[v][p]=1;
                a[v]++;
            }
        }
    }
    for(int i=0;i<task.size();++i)
    if(res<a[task[i]]){
        res=a[task[i]];
        ans=task[i];
    }
    cout<<ans;
    // for(int i=0;i<task.size();++i)
    //    cout<<a[task[i]]<<"  belong to "<<task[i]<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define N (int ) 1e5+5
int n,m,d[N];
int a[N]={1};
int res=-1,ans=0;
map<int,int> mp[N];
map<int,int> cunt;
int cnt=0;
vector<int> task;
int main(){
    //freopen("era.cpp","r
    cin>>n>>m;
    int color=0;
    for(int i=1;i<=n;++i)  {
        scanf("%d",&d[i]),color=max(color,d[i]);
        if(!cunt.count(d[i]))  cunt[d[i]]=++cnt,task.push_back(d[i]);
    }
    while(m--){
        int p,q;
        scanf("%d%d",&p,&q);
        int u=d[p],v=d[q];
        if(u!=v && !mp[u].count(v)){
            mp[u][v]=1;
            a[u]++;
            a[v]++;
            mp[v][u]=1;
        }
    }
    for(int i=0;i<task.size();++i)
    if(res<a[task[i]]){
        res=a[task[i]];
        ans=task[i];
    }
    cout<<ans;
   //for(int i=0;i<task.size();++i)
     //   cout<<a[task[i]]<<"  belong to "<<task[i]<<endl;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#define nmax 100000+6
const int INF=(int)1e9+7;

using namespace std;
typedef set<int> si;

int n, u, v, m, temp;
set<int> color;
vector< set<int> > adjlist;
int c[nmax], p, ans;

int main() {
    //freopen("color.inp","r",stdin);
    scanf("%d %d",&n,&m);
    temp=-INF;
    for (int i=0;i<n;i++) {
        scanf("%d",&c[i]);
        if (c[i]>temp) temp=c[i];
        color.insert(c[i]);
    }
    adjlist.assign(temp+2,set<int>());
    for (int i=0;i<m;i++) {
        cin>>u>>v;
        u--;
        v--;
        if (c[u]!=c[v]) {
            adjlist[c[u]].insert(c[v]);
            adjlist[c[v]].insert(c[u]);
        }
    }
    p=-INF;
    set<int>::iterator it;
    for (it=color.begin();it!=color.end();++it) {
        int v=adjlist[*it].size();
        if (v>p) {
            p=v;
            ans=(*it);
        }
    }
    printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
#define M 621998
#define II pair< long long , long long >
#define III pair< II , long long >
#define FIN freopen("test.txt","r",stdin)
#define FOUT freopen("test_out.txt","w",stdout)
#define vii vector< II >
#define vi vector< long long >
#define viii vector< III >
#define vvi vector< vi >
#define vvii vector< vii >
#define T 1
#define F 0
#define PB push_back
#define vstr vector< string >
#define SS pair< string , string >
#define vss vector< SS >
#define SSS pair< string , SS >
#define vsss vector < SSS >
#define P push
#define PP pop()
#define TT top()
#define FF front()
#define pq_max priority queue
#define pq_min priority_queue< int, vector<int>, greater<int> >

#define X first
#define Y second
long long const oo=1622731998;

/*
#define X first.first
#define Y first.second
#define Z second
*/
//__builtin_popcount()

set<int> _set[M];
int color[M];

int main(){
    //FIN;
    int n,m,i,a,b,j,ma,ans;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        cin>>color[i];
    }
    for(i=1;i<=m;i++){
        cin>>a>>b;
        _set[ color[a] ].insert( color[b] );
        _set[ color[b] ].insert( color[a] );
    }
    ma=0;
    for(i=1;i<=n;i++){
        //cout<<_set[i].size()<<' '<<ma<<' '<<( _set[i].size()>ma )<<endl;
        if( _set[i].size()>ma ){
            ma=_set[i].size();
            ans=i;
            //cout<<ans<<endl;
        }
    }
    cout<<ans;

}


#include<bits/stdc++.h>
using namespace std;
#define N (int ) 1e5+5
int n,m,d[N];
int a[N]={1};
int res=-1,ans=0;
map<int,int> mp[N];
map<int,int> cunt;
int cnt=0;
vector<int> task;
int main(){
    //freopen("era.cpp","r",stdin);
    cin>>n>>m;
    int color=0;
    for(int i=1;i<=n;++i)  {
        scanf("%d",&d[i]),color=max(color,d[i]);
        if(!cunt.count(d[i]))  cunt[d[i]]=++cnt,task.push_back(d[i]);
    }
    while(m--){
        int p,q;
        scanf("%d%d",&p,&q);
        int u=d[p],v=d[q];
        if(u!=v && !mp[u].count(v)){
            mp[u][v]=1;
            a[u]++;
            a[v]++;
            mp[v][u]=1;
        }
    }
    for(int i=0;i<task.size();++i)
    if(res<a[task[i]]){
        res=a[task[i]];
        ans=task[i];
    }
    cout<<ans;
   //for(int i=0;i<task.size();++i)
     //   cout<<a[task[i]]<<"  belong to "<<task[i]<<endl;
}


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

vector < int > c;
map < int , set < int > >::iterator it;

map < int , set < int > > s;

typedef pair < int , int > ii;

vector < ii > vii;
bool cmp(ii a,ii b){ return ( (a.second > b.second) or (a.second==b.second and a<b)); }

int main(){

    //freopen("test.inp","r",stdin);
    int V,E;
    scanf("%d %d",&V,&E);
    c.assign(V+1,0);

    set < int > st;

    for (int i=1;i<=V;i++){
        scanf("%d",&c[i]);
        st.insert(c[i]);
    }

    while(E--){
        int u,v;
        scanf("%d %d",&u,&v);
        if (c[u]!= c[v]){
            s[c[u]].insert(c[v]);
            s[c[v]].insert(c[u]);
        }
    }

    int maxx = 0;
    int minn = V+1;

    for (it = s.begin();it!=s.end();++it){
        int k = (int)(it->second).size();

        //cout << "i = " << it->first << " k = " << k << endl;
        vii.push_back(ii(it->first,k));
    }

    sort(vii.begin(),vii.end(),cmp);

    cout << vii[0].first << '\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 621998
#define II pair< long long , long long >
#define III pair< II , long long >
#define FIN freopen("test.txt","r",stdin)
#define FOUT freopen("test_out.txt","w",stdout)
#define vii vector< II >
#define vi vector< long long >
#define viii vector< III >
#define vvi vector< vi >
#define vvii vector< vii >
#define T 1
#define F 0
#define PB push_back
#define vstr vector< string >
#define SS pair< string , string >
#define vss vector< SS >
#define SSS pair< string , SS >
#define vsss vector < SSS >
#define P push
#define PP pop()
#define TT top()
#define FF front()
#define pq_max priority queue
#define pq_min priority_queue< int, vector<int>, greater<int> >

#define X first
#define Y second
long long const oo=1622731998;

/*
#define X first.first
#define Y first.second
#define Z second
*/
//__builtin_popcount()

set<int> _set[M];
int color[M];

int main(){
    //FIN;
    int n,m,i,a,b,j,ma,ans;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        cin>>color[i];
    }
    for(i=1;i<=m;i++){
        cin>>a>>b;
        _set[ color[a] ].insert( color[b] );
        _set[ color[b] ].insert( color[a] );
    }
    ma=0;
    for(i=1;i<=100005;i++){
        //cout<<_set[i].size()<<' '<<ma<<' '<<( _set[i].size()>ma )<<endl;
        if( _set[i].size()>ma ){
            ma=_set[i].size();
            ans=i;
            //cout<<ans<<endl;
        }
    }
    cout<<ans;

}


#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
vector <int> a[100100],color[100100];
int c[100100];
int dfs(int x)
{
    bool check[100100];
    int ans=0;
    memset(check,false,sizeof(check));
        check[x]=true;
    for(int i=0;i<color[x].size();i++)
    {
        int tmp=color[x][i];
        for(int j=0;j<a[tmp].size();j++)
        {
            if(check[c[a[tmp][j]]]!=true)
                {
                //printf("%d %d\n",x,c[a[tmp][j]]);
                    ans++;
                    check[c[a[tmp][j]]]=true;
                }
        }
    }
    return ans;
}
int main()
{
    int n,i,m,x,y,imax=-1,save=999999999;
    bool ch[100010];
    //freopen("test.inp","r",stdin);
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        color[x].push_back(i);
        c[i]=x;
    }
    while(m--)
    {
        scanf("%d %d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(i=1;i<=n;i++)
    {
        if(ch[c[i]]!=true)
        {
        ch[c[i]]=true;
        int tmp=dfs(c[i]);
        //printf("%d\n",tmp);
        if(imax<=tmp)
        {
            imax=tmp;
            if(c[i]<save)
            save=c[i];
        }
        }
    }
    printf("%d",save);
}


#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
vector <int> a[100100],color[100100];
int c[100100];
int dfs(int x)
{
    bool check[100100];
    int ans=0;
    memset(check,false,sizeof(check));
    for(int i=0;i<color[x].size();i++)
    {
        int tmp=color[x][i];
        for(int j=0;j<a[tmp].size();j++)
        {
            if(check[c[a[tmp][j]]]!=true)
            if(c[a[tmp][j]]!=c[tmp])
                {
                    ans++;
                    check[c[a[tmp][j]]]=true;
                }
        }
    }
    return ans;
}
int main()
{
    int n,i,m,x,y,imax=-1,save;
    bool ch[100010];
    //freopen("test.inp","r",stdin);
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        color[x].push_back(i);
        c[i]=x;
    }
    while(m--)
    {
        scanf("%d %d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(i=1;i<=n;i++)
    {
        if(ch[c[i]]!=true)
        {
        ch[c[i]]=true;
        int tmp=dfs(c[i]);
        //printf("%d\n",tmp);
        if(imax<tmp)
        {
            imax=tmp;
            save=c[i];
        }
        }
    }
    printf("%d",save);
}


#include<stdio.h>
#include<set>
#include<vector>
#define MAX 100200
#include<string.h>
#include<algorithm>
using namespace std;
vector<int> ans;
set<int> ss;
set<int> st[MAX];
int cnt[MAX];
int c[MAX];
main(){
    //freopen("test.inp","r",stdin);
    int N,M;
    scanf("%d %d",&N,&M);
    for(int i=1;i<=N;i++)
      scanf("%d",&c[i]);
    memset(cnt,0,sizeof cnt);
    for(int i=1;i<=M;i++){
        int u,v;
        scanf("%d %d",&u,&v);
        if(c[u]==c[v]) continue;
        if(ss.find(c[u])==ss.end()) {
            ss.insert(c[u]);
            ans.push_back(c[u]);
        }
        if(st[c[u]].find(c[v])==st[c[u]].end()){
            cnt[c[u]]++;
            st[c[u]].insert(c[v]);
        }
        if(ss.find(c[v])==ss.end()){
            ss.insert(c[v]);
            ans.push_back(c[v]);
        }
        if(st[c[v]].find(c[u])==st[c[v]].end()){
            cnt[c[v]]++;
            st[c[v]].insert(c[u]);
        }
    }
    sort(ans.begin(),ans.end());
    int mmax=-1;
    int re=0;
    for(int i=0;i<ans.size();i++){
        if(cnt[ans[i]]>mmax){
            mmax=cnt[ans[i]];
            re=ans[i];
        }
    }
    printf("%d",re);
}


#include<stdio.h>
#include<set>
#include<vector>
#define MAX 100200
#include<string.h>
#include<algorithm>
using namespace std;
vector<int> ans;
set<int> ss;
set<int> st[MAX];
int cnt[MAX];
int c[MAX];
main(){
    //freopen("test.inp","r",stdin);
    int N,M;
    scanf("%d %d",&N,&M);
    for(int i=1;i<=N;i++)
      scanf("%d",&c[i]);
    memset(cnt,0,sizeof cnt);
    for(int i=1;i<=M;i++){
        int u,v;
        scanf("%d %d",&u,&v);
        if(ss.find(c[u])==ss.end()) {
            ss.insert(c[u]);
            ans.push_back(c[u]);
        }
        if(ss.find(c[v])==ss.end()){
            ss.insert(c[v]);
            ans.push_back(c[v]);
        }
        if(c[u]==c[v]) continue;
        if(st[c[u]].find(c[v])==st[c[u]].end()){
            cnt[c[u]]++;
            st[c[u]].insert(c[v]);
        }
        if(st[c[v]].find(c[u])==st[c[v]].end()){
            cnt[c[v]]++;
            st[c[v]].insert(c[u]);
        }
    }
    sort(ans.begin(),ans.end());
    int mmax=cnt[ans[0]];
    int re=ans[0];
    for(int i=1;i<ans.size();i++)
        if(cnt[ans[i]]>mmax){
            mmax=cnt[ans[i]];
            re=ans[i];
        }
    printf("%d",re);
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int n,m;
vector<vector<int> > E;
vector<vector<int> > C;

int main(){
    //freopen("input.inp","r",stdin);
    scanf("%d%d",&n,&m);
    int c;
    int x[n+1];
    E.resize(n);
    C.resize(100001);
    for(int i=0;i<n;i++){
        scanf("%d",x+i);
        C[x[i]].push_back(i);
    }
    int a,b;
    while(m--){
        scanf("%d%d",&a,&b);
        a--;b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    int imax=1,amax=-1;
    for(int i=1;i<=100000;i++)if(!C[i].empty()){
        set<int> s;
        for(unsigned j=0;j<C[i].size();j++)
            for(unsigned k=0;k<E[C[i][j]].size();k++){
                if(x[E[C[i][j]][k]]!=i)s.insert(x[E[C[i][j]][k]]);
                //printf("%d\n",E[C[i][j]][k]);
            }
        int tmp=s.size();
        if(tmp>amax){
            amax=tmp;
            imax=i;
        }
    }
    printf("%d",imax);
}


#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
vector <int> a[100100],color[100100];
int c[100100];
int dfs(int x)
{
    bool check[100100];
    int ans=0;
    memset(check,false,sizeof(check));
    for(int i=0;i<color[x].size();i++)
    {
        int tmp=color[x][i];
        for(int j=0;j<a[tmp].size();j++)
        {
            if(check[a[tmp][j]]!=true)
            if(c[a[tmp][j]]!=c[tmp])
                {
                    ans++;
                    check[a[tmp][j]]=true;
                }
        }
    }
    return ans;
}
int main()
{
    int n,i,m,x,y,imax=-1,save;
    bool ch[100100];
    //freopen("test.inp","r",stdin);
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        color[x].push_back(i);
        c[i]=x;
    }
    while(m--)
    {
        scanf("%d %d",&x,&y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(i=1;i<=n;i++)
    {
        if(ch[c[i]]!=true)
        {
        ch[c[i]]=true;
        int tmp=dfs(c[i]);
        if(imax<tmp)
        {
            imax=tmp;
            save=c[i];
        }
        }
    }
    printf("%d",save);
}


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

map < int , set < int > > s;

vector < int > c;
map < int , set < int > >::iterator it;

int main(){

    //freopen("test.inp","r",stdin);
    int V,E;
    scanf("%d %d",&V,&E);
    c.assign(V+1,0);

    set < int > st;

    for (int i=1;i<=V;i++){
        scanf("%d",&c[i]);
        st.insert(c[i]);
    }

    while(E--){
        int u,v;
        scanf("%d %d",&u,&v);
        if (c[u]!= c[v]){
            s[c[u]].insert(c[v]);
            s[c[v]].insert(c[u]);
        }
    }

    int maxx = 0;
    int minn = V+1;

    for (it = s.begin();it!=s.end();++it){
        int k = (int)(it->second).size();

        //cout << "i = " << it->first << " k = " << k << endl;
        if (k>maxx){
            minn = it->first;
            maxx = k;
        }
        else if (k==maxx)
            minn = min ( minn , it->first);
    }

    cout << minn << '\n';
    return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<sstream>
#include<cmath>
#include<cctype>
#include<list>
#include<ctime>
#include<iomanip>
#include<set>
#include<string.h>
#include<stdlib.h>

#define inf ((1<<30)-1)

#define MM 1000009

#define NN 100009

#define maxv(A,B) (A>B?A:B)

#define minv(A,B) (A>B?B:A)

using namespace std;

int lod[NN],cnt[NN],idx[NN];

vector< pair<int,int> > g[NN];
int main()
{
	int i,j,k,m,n,mx,u,v,res;
	while( scanf("%d %d",&n,&m)==2 )
	{
		for( i=0;i<NN;i++ )
		{
			g[i].clear();
			cnt[i]=0;
		}

		for( i=0;i<n;i++ )
		{
			scanf("%d",&lod[i]);
			idx[ lod[i] ]=i;
		}
		for( i=0;i<m;i++ )
		{
			scanf("%d %d",&u,&v);
			u--;v--;
			g[u].push_back(make_pair(v,lod[u]));
			g[v].push_back( make_pair(u,lod[v]) );
		}
		int res=mx=0;
		for( i=0;i<n;i++ )
		{
			int c=lod[i];
			for( j=0;j<g[i].size();j++ )
			{
				v=g[i][j].first;
				if( lod[i]!=lod[v] ) cnt[c]++;
			}
		}
		for( i=0;i<NN;i++ )
		{
			if( cnt[i]>=mx )
			{
				int tt=idx[i];
				if( cnt[i]>mx )
				{
					res=lod[tt];
					mx=cnt[i];
				}
				else if( mx==cnt[i]  && res> lod[ idx[i]  ])
				{
					res=lod[ idx[i] ];
				}
			}
		}
		sort(lod,lod+n);
		if(m==0 || res==0) res=lod[0];
		printf("%d\n",res);
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<sstream>
#include<cmath>
#include<cctype>
#include<list>
#include<ctime>
#include<iomanip>
#include<set>
#include<string.h>
#include<stdlib.h>

#define inf ((1<<30)-1)

#define MM 1000009

#define NN 100009

#define maxv(A,B) (A>B?A:B)

#define minv(A,B) (A>B?B:A)

using namespace std;

int lod[NN],cnt[NN],idx[NN],visit[NN];

vector< pair<int,int> > g[NN];
int main()
{
	int i,j,k,m,n,mx,u,v,res;
	while( scanf("%d %d",&n,&m)==2 )
	{
		for( i=0;i<NN;i++ )
		{
			g[i].clear();
			cnt[i]=0;
			visit[i]=-1;
		}

		for( i=0;i<n;i++ )
		{
			scanf("%d",&lod[i]);
			idx[ lod[i] ]=i;
		}
		for( i=0;i<m;i++ )
		{
			scanf("%d %d",&u,&v);
			u--;v--;
			g[u].push_back(make_pair(v,lod[u]));
			g[v].push_back( make_pair(u,lod[v]) );
			visit[u]=visit[v]=0;
		}
		int res=mx=0;
		for( i=0;i<n;i++ )
		{
			int c=lod[i];
			for( j=0;j<g[i].size();j++ )
			{
				v=g[i][j].first;
				if( lod[i]!=lod[v] ) cnt[c]++;
			}
		}
		for( i=0;i<NN;i++ )
		{
			if( cnt[i]>=mx )
			{
				int tt=idx[i];
				if( cnt[i]>mx )
				{
					res=lod[tt];
					mx=cnt[i];
				}
				else if( mx==cnt[i]  && res> lod[ idx[i]  ])
				{
					res=lod[ idx[i] ];
				}
			}
		}
		for( i=0;i<n;i++ )
		{
			if( visit[i]==-1 && lod[i]<res && mx==1 ) res=lod[i];
		}
		sort(lod,lod+n);

		if(m==0 || res==0) res=lod[0];
		printf("%d\n",res);
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<sstream>
#include<cmath>
#include<cctype>
#include<list>
#include<ctime>
#include<iomanip>
#include<set>
#include<string.h>
#include<stdlib.h>

#define inf ((1<<30)-1)

#define MM 1000009

#define NN 100009

#define maxv(A,B) (A>B?A:B)

#define minv(A,B) (A>B?B:A)

using namespace std;

int lod[NN],cnt[NN],idx[NN],visit[NN];

vector< pair<int,int> > g[NN];
int main()
{
	int i,j,k,m,n,mx,u,v,res;
	while( scanf("%d %d",&n,&m)==2 )
	{
		for( i=0;i<NN;i++ )
		{
			g[i].clear();
			cnt[i]=0;
			visit[i]=-1;
		}

		for( i=0;i<n;i++ )
		{
			scanf("%d",&lod[i]);
			idx[ lod[i] ]=i;
		}
		for( i=0;i<m;i++ )
		{
			scanf("%d %d",&u,&v);
			u--;v--;
			g[u].push_back(make_pair(v,lod[u]));
			g[v].push_back( make_pair(u,lod[v]) );
			visit[u]=visit[v]=0;
		}
		int res=mx=0;
		for( i=0;i<n;i++ )
		{
			int c=lod[i];
			for( j=0;j<g[i].size();j++ )
			{
				v=g[i][j].first;
				if( lod[i]!=lod[v] ) cnt[c]++;
			}
		}
		for( i=0;i<NN;i++ )
		{
			if( cnt[i]>=mx )
			{
				int tt=idx[i];
				if( cnt[i]>mx )
				{
					res=lod[tt];
					mx=cnt[i];
				}
				else if( mx==cnt[i]  && res> lod[ idx[i]  ])
				{
					res=lod[ idx[i] ];
				}
			}
		}
		for( i=0;i<n;i++ )
		{
			if( visit[i]==-1 && lod[i]<res ) res=lod[i];
		}
		sort(lod,lod+n);
		if(m==0 || res==0) res=lod[0];
		printf("%d\n",res);
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<sstream>
#include<cmath>
#include<cctype>
#include<list>
#include<ctime>
#include<iomanip>
#include<set>
#include<string.h>
#include<stdlib.h>

#define inf ((1<<30)-1)

#define MM 1000009

#define NN 100009

#define maxv(A,B) (A>B?A:B)

#define minv(A,B) (A>B?B:A)

using namespace std;

int lod[NN],cnt[NN],idx[NN],visit[NN];

vector< pair<int,int> > g[NN];

set<int> S[NN];

int main()
{
	int i,j,k,m,n,mx,u,v,res;
		scanf("%d %d",&n,&m);
		for( i=1;i<=n;i++ )
		{
			scanf("%d",&lod[i]);
		}
		for( i=0;i<m;i++ )
		{
			scanf("%d %d",&u,&v);
			u=lod[u];
			v=lod[v];
			if( u==v ) continue;
			S[u].insert(v);
			S[v].insert(u);
		}
		res=lod[1],mx=0;
		for( i=1;i<=n;i++ )
		{
			k=lod[i];
			if( S[k].size()>mx )
			{
				mx=S[k].size();
				res=k;
			}
			else if( S[k].size()==mx ) res=minv(res,k);
		}
		printf("%d\n",res);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<sstream>
#include<cmath>
#include<cctype>
#include<list>
#include<ctime>
#include<iomanip>
#include<set>
#include<string.h>
#include<stdlib.h>

#define inf ((1<<30)-1)

#define MM 1000009

#define NN 100009

#define maxv(A,B) (A>B?A:B)

#define minv(A,B) (A>B?B:A)

using namespace std;

int lod[NN],cnt[NN],idx[NN];

vector< pair<int,int> > g[NN];
int main()
{
	int i,j,k,m,n,mx,u,v,res;
	while( scanf("%d %d",&n,&m)==2 )
	{
		for( i=0;i<NN;i++ )
		{
			g[i].clear();
			cnt[i]=0;
		}

		for( i=0;i<n;i++ )
		{
			scanf("%d",&lod[i]);
			idx[ lod[i] ]=i;
		}
		for( i=0;i<m;i++ )
		{
			scanf("%d %d",&u,&v);
			u--;v--;
			g[u].push_back(make_pair(v,lod[u]));
			g[v].push_back( make_pair(u,lod[v]) );
		}
		int res=mx=0;
		for( i=0;i<n;i++ )
		{
			int c=lod[i];
			for( j=0;j<g[i].size();j++ )
			{
				v=g[i][j].first;
				if( lod[i]!=lod[v] ) cnt[c]++;
			}
		}
		for( i=0;i<NN;i++ )
		{
			if( cnt[i]>=mx )
			{
				int tt=idx[i];
				if( cnt[i]>mx )
				{
					res=lod[tt];
					mx=cnt[i];
				}
				else if( mx==cnt[i]  && res> lod[ idx[i]  ])
				{
					res=lod[ idx[i] ];
				}
			}
		}
		if(m==0 || res==0) res=lod[0];
		printf("%d\n",res);
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<sstream>
#include<cmath>
#include<cctype>
#include<list>
#include<ctime>
#include<iomanip>
#include<set>
#include<string.h>
#include<stdlib.h>

#define inf ((1<<30)-1)

#define MM 1000009

#define NN 100009

#define maxv(A,B) (A>B?A:B)

#define minv(A,B) (A>B?B:A)

using namespace std;

int lod[NN],cnt[NN],idx[NN];

vector< pair<int,int> > g[NN];
int main()
{
	int i,j,k,m,n,mx,u,v,res;
	while( scanf("%d %d",&n,&m)==2 )
	{
		for( i=0;i<NN;i++ )
		{
			g[i].clear();
			cnt[i]=0;
		}

		for( i=0;i<n;i++ )
		{
			scanf("%d",&lod[i]);
			idx[ lod[i] ]=i;
		}
		for( i=0;i<m;i++ )
		{
			scanf("%d %d",&u,&v);
			u--;v--;
			g[u].push_back(make_pair(v,lod[u]));
			g[v].push_back( make_pair(u,lod[v]) );
		}
		int res=mx=0;
		for( i=0;i<n;i++ )
		{
			int c=lod[i];
			for( j=0;j<g[i].size();j++ )
			{
				v=g[i][j].first;
				if( lod[i]!=lod[v] ) cnt[c]++;
			}
		}
		for( i=0;i<NN;i++ )
		{
			if( cnt[i]>=mx )
			{
				int tt=idx[i];
				if( cnt[i]>mx )
				{
					res=lod[tt];
					mx=cnt[i];
				}
				else if( mx==cnt[i]  && res> lod[ idx[i]  ])
				{
					res=lod[ idx[i] ];
				}
			}
		}
		if(m==0) res=lod[0];
		printf("%d\n",res);
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<sstream>
#include<cmath>
#include<cctype>
#include<list>
#include<ctime>
#include<iomanip>
#include<set>
#include<string.h>
#include<stdlib.h>

#define inf ((1<<30)-1)

#define MM 1000009

#define NN 100009

#define maxv(A,B) (A>B?A:B)

#define minv(A,B) (A>B?B:A)

using namespace std;

int lod[NN],cnt[NN],idx[NN],visit[NN];

vector< pair<int,int> > g[NN];
int main()
{
	int i,j,k,m,n,mx,u,v,res;
	while( scanf("%d %d",&n,&m)==2 )
	{
		for( i=0;i<NN;i++ )
		{
			g[i].clear();
			cnt[i]=0;
			visit[i]=-1;
		}

		for( i=0;i<n;i++ )
		{
			scanf("%d",&lod[i]);
			idx[ lod[i] ]=i;
		}
		for( i=0;i<m;i++ )
		{
			scanf("%d %d",&u,&v);
			u--;v--;
			g[u].push_back(make_pair(v,lod[u]));
			g[v].push_back( make_pair(u,lod[v]) );
			visit[u]=visit[v]=0;
		}
		int res=mx=0;
		for( i=0;i<n;i++ )
		{
			int c=lod[i];
			for( j=0;j<g[i].size();j++ )
			{
				v=g[i][j].first;
				if( lod[i]!=lod[v] ) cnt[c]++;
			}
		}
		for( i=0;i<NN;i++ )
		{
			if( cnt[i]>=mx )
			{
				int tt=idx[i];
				if( cnt[i]>mx )
				{
					res=lod[tt];
					mx=cnt[i];
				}
				else if( mx==cnt[i]  && res> lod[ idx[i]  ])
				{
					res=lod[ idx[i] ];
				}
			}
		}
		for( i=0;i<n;i++ )
		{
			if( visit[i]==-1 && lod[i]<res && mx==1 ) res=lod[i];
		}
		sort(lod,lod+n);
		if(m==0 || res==0) res=lod[0];
		printf("%d\n",res);
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<sstream>
#include<cmath>
#include<cctype>
#include<list>
#include<ctime>
#include<iomanip>
#include<set>
#include<string.h>
#include<stdlib.h>

#define inf ((1<<30)-1)

#define MM 1000009

#define NN 100009

#define maxv(A,B) (A>B?A:B)

#define minv(A,B) (A>B?B:A)

using namespace std;

int lod[NN],cnt[NN],idx[NN],visit[NN];

vector< pair<int,int> > g[NN];

set<int> S[NN];

int main()
{
	int i,j,k,m,n,mx,u,v,res;
		scanf("%d %d",&n,&m);
		for( i=1;i<=n;i++ )
		{
			scanf("%d",&lod[i]);
		}
		for( i=0;i<m;i++ )
		{
			scanf("%d %d",&u,&v);
			u=lod[u];
			v=lod[v];
			if( u==v ) continue;
			S[u].insert(v);
			S[v].insert(u);
		}
		res=0,mx=0;
		for( i=1;i<=n;i++ )
		{
			k=lod[i];
			if( S[k].size()>mx )
			{
				mx=S[k].size();
				res=k;
			}
			else if( S[k].size()==mx ) res=minv(res,k);
		}
		printf("%d\n",res);
	return 0;
}


#include <stdio.h>
#include <vector>
#include <set>

using namespace std;

int n, m, i, color[100001], maxx, pamti, broj1, broj2, col1, col2;
    set <int> card[100001];

int main(){

    scanf("%d%d", &n, &m);
    for (i=0; i<n; i++){
        scanf("%d", &color[i]);
    }
    maxx = 0;
    pamti = 0;
    for (i=0; i<m; i++){
        scanf("%d%d", &broj1, &broj2);
        col1 = color[broj1-1];
        col2 = color[broj2-1];
        if (col1!=col2){
            card[col1].insert(col2);
            card[col2].insert(col1);
            if (card[col1].size()>maxx){
                maxx = card[col1].size();
                pamti = col1;
            }
            if (card[col2].size()>maxx){
                maxx = card[col2].size();
                pamti = col2;
            }
        }
    }
    printf("%d", pamti);
    return 0;
}


#include <stdio.h>
#include <vector>
#include <set>

using namespace std;

int n, m, i, color[100001], maxx, pamti, broj1, broj2, col1, col2;
set <int> card[100001];

int main(){

    scanf("%d%d", &n, &m);
    for (i=0; i<=100000; i++){
        card[i].clear();
    }
    for (i=0; i<n; i++){
        scanf("%d", &color[i]);
    }
    maxx = 0;
    pamti = 0;
    for (i=0; i<m; i++){
        scanf("%d%d", &broj1, &broj2);
        col1 = color[broj1-1];
        col2 = color[broj2-1];
        if (col1!=col2){
            card[col1].insert(col2);
            card[col2].insert(col1);
        }
    }
    for (i=0; i<=100000; i++){
        if (card[i].size()>maxx){
            maxx = card[i].size();
            pamti = i;
        }
    }
    printf("%d", pamti);
    return 0;
}


#include <stdio.h>
#include <vector>
#include <set>

using namespace std;

int n, m, i, color[100001], maxx, pamti, broj1, broj2, col1, col2;
int card[100001];

int main(){

    scanf("%d%d", &n, &m);
    for (i=0; i<=100000; i++){
        card[i]=0;
    }
    for (i=0; i<n; i++){
        scanf("%d", &color[i]);
    }
    maxx = 0;
    pamti = 0;
    for (i=0; i<m; i++){
        scanf("%d%d", &broj1, &broj2);
        col1 = color[broj1-1];
        col2 = color[broj2-1];
        if (col1!=col2){
            card[col1]++;
            card[col2]++;
        }
    }
    for (i=0; i<=100000; i++){
        if (card[i]>maxx){
            maxx = card[i];
            pamti = i;
        }
    }
    printf("%d", pamti);
    return 0;
}


#include <stdio.h>
#include <vector>
#include <set>

using namespace std;

int n, m, i, color[100001], maxx, pamti, broj1, broj2, col1, col2;
set <int> card[100001];

int main(){

    scanf("%d%d", &n, &m);
    for (i=0; i<=100000; i++){
        card[i].clear();
    }
    for (i=0; i<n; i++){
        scanf("%d", &color[i]);
    }
    maxx = -1;
    pamti = color[0];
    for (i=0; i<m; i++){
        scanf("%d%d", &broj1, &broj2);
        col1 = color[broj1-1];
        col2 = color[broj2-1];
        if (col1!=col2){
            card[col1].insert(col2);
            card[col2].insert(col1);
        }
    }
    for (i=0; i<=100000; i++){
        if (card[i].size()>maxx){
            maxx = card[i].size();
            pamti = i;
        }
    }
    printf("%d", pamti);
    return 0;
}


#include <stdio.h>
#include <vector>
#include <set>

using namespace std;

int n, m, i, color[100001], maxx, pamti, broj1, broj2, col1, col2;
set <int> card[100001];
bool sretnato[100001];

int main(){

    scanf("%d%d", &n, &m);
    for (i=0; i<=100000; i++){
        card[i].clear();
        sretnato[i] = false;
    }
    for (i=0; i<n; i++){
        scanf("%d", &color[i]);
        sretnato[color[i]] = true;
    }
    maxx = -1;
    pamti = color[0];
    for (i=0; i<m; i++){
        scanf("%d%d", &broj1, &broj2);
        col1 = color[broj1-1];
        col2 = color[broj2-1];
        if (col1!=col2){
            card[col1].insert(col2);
            card[col2].insert(col1);
        }
    }
    for (i=0; i<=100000; i++){
        broj1 = card[i].size();
        if ((broj1>maxx) && (sretnato[i]==true)){
            maxx = card[i].size();
            pamti = i;
        }
    }
    printf("%d", pamti);
    return 0;
}


#include <stdio.h>
#include <vector>
#include <set>

using namespace std;

int n, m, i, color[100001], maxx, pamti, broj1, broj2, col1, col2;
set <int> card[100001];

int main(){

    scanf("%d%d", &n, &m);
    for (i=0; i<=100000; i++){
        card[i].clear();
    }
    for (i=0; i<n; i++){
        scanf("%d", &color[i]);
    }
    maxx = 0;
    pamti = 1;
    for (i=0; i<m; i++){
        scanf("%d%d", &broj1, &broj2);
        col1 = color[broj1-1];
        col2 = color[broj2-1];
        if (col1!=col2){
            card[col1].insert(col2);
            card[col2].insert(col1);
        }
    }
    for (i=0; i<=100000; i++){
        if (card[i].size()>maxx){
            maxx = card[i].size();
            pamti = i;
        }
    }
    printf("%d", pamti);
    return 0;
}


#include <stdio.h>
#include <vector>
#include <set>

using namespace std;

int n, m, i, color[100001], maxx, pamti, broj1, broj2, col1, col2;
    set <int> card[100001];

int main(){

    scanf("%d%d", &n, &m);
    for (i=0; i<n; i++){
        scanf("%d", &color[i]);
    }
    maxx = 0;
    pamti = 0;
    for (i=0; i<m; i++){
        scanf("%d%d", &broj1, &broj2);
        col1 = color[broj1-1];
        col2 = color[broj2-1];
        if (col1!=col2){
            card[col1].insert(col2);
            card[col2].insert(col1);
            if (card[col1].size()>maxx){
                maxx = card[col1].size();
                pamti = col1;
            }
            if (card[col2].size()>maxx){
                maxx = card[col2].size();
                pamti = col2;
            }
            if ((card[col1].size()==maxx) && (col1<pamti)){
                maxx = card[col1].size();
                pamti = col1;
            }
            if ((card[col2].size()==maxx) && (col2<pamti)){
                pamti = col2;
            }
        }
    }
    printf("%d", pamti);
    return 0;
}


#include <stdio.h>
#include <vector>
#include <set>

using namespace std;

int n, m, i, color[100001], maxx, pamti, broj1, broj2, col1, col2;
set <int> card[100001];

int main(){

    scanf("%d%d", &n, &m);
    for (i=0; i<=100000; i++){
        card[i].clear();
    }
    for (i=0; i<n; i++){
        scanf("%d", &color[i]);
    }
    maxx = 0;
    pamti = color[0];
    for (i=0; i<m; i++){
        scanf("%d%d", &broj1, &broj2);
        col1 = color[broj1-1];
        col2 = color[broj2-1];
        if (col1!=col2){
            card[col1].insert(col2);
            card[col2].insert(col1);
        }
    }
    for (i=0; i<=100000; i++){
        if (card[i].size()>maxx){
            maxx = card[i].size();
            pamti = i;
        }
    }
    printf("%d", pamti);
    return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);
    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }
    m=m*2;
    sort(g+1,g+1+m);
    int sol,cnt;
    sol=0,cnt=0;
    int trn=0;
    for (a=1; a<=m; a++)
    {
        if (g[a].p==g[a-1].p)
        {
            if (g[a].k>g[a-1].k && g[a].p!=g[a].k) trn++;
            if (trn>cnt)
            cnt=trn, sol=g[a].p;
        }
        else
        {
            if (g[a].p!=g[a].k)
            trn=1;
            else
            trn=0;
            if (trn>cnt)
            cnt=trn, sol=g[a].p;
        }
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);
    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }
    m=m*2;
    sort(g+1,g+1+m);
    int sol,cnt;

    for (a=1; a<=n; a++)
    if (sol>col[a])
    sol=col[a];
    cnt=0;

    int trn=1;
    for (a=1; a<=m; a++)
    {
        if (g[a].p==g[a-1].p)
        {
            if (g[a].k>g[a-1].k && g[a].k!=g[a].p)trn++;
            if (trn>cnt)
            cnt=trn, sol=g[a].p;
        }
        else
        trn=1;
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);
    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }
    m=m*2;
    sort(g+1,g+1+m);
    int sol,cnt;
    sol=0,cnt=0;
    int trn=1;
    for (a=1; a<=m; a++)
    {
        if (g[a].p==g[a-1].p && g[a].k>g[a-1].k)
        {
            trn++;
            if (trn>cnt)
            cnt=trn, sol=g[a].p;
        }
        else
        trn=1;
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);
    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }
    m=m*2;
    sort(g+1,g+1+m);
    int sol,cnt;
    sol=0,cnt=0;

    int boja,vr,last;
    boja=-1000;

    for (a=1; a<=m; a++)
    {
        if (boja==g[a].p)
        {
            if (g[a].k!=last)
            vr++, last=g[a].k;
            if (vr>cnt)
            cnt=vr, sol=boja;
        }
        else
        {
            boja=g[a].p;
            last=g[a].k;
            if (last!=boja) vr=1; else vr=0;
            if (vr>cnt)
            cnt=vr, sol=boja;
        }
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);

    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }

    m=m*2;
    sort(g+1,g+1+m);
    int sol,cnt;
    sol=0,cnt=0;

    int boja,vr,last;
    boja=-1000;

    for (a=1; a<=m; a++)
    {
        if (boja==g[a].p)
        {
            if (g[a].k!=last && g[a].k!=boja)
            vr++, last=g[a].k;
            if (vr>cnt)
            cnt=vr, sol=boja;
        }
        else
        {
            boja=g[a].p;
            last=g[a].k;
            if (last!=boja) vr=1; else vr=0;
            if (vr>cnt)
            cnt=vr, sol=boja;
        }
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);
    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }
    m=m*2;
    sort(g+1,g+1+m);
    int sol,cnt;

    for (a=1; a<=n; a++)
    if (sol>col[a])
    sol=col[a];
    cnt=0;

    int trn=0;
    for (a=1; a<=m; a++)
    {
        if (g[a].p==g[a-1].p)
        {
            if (g[a].k>g[a-1].k && g[a].k!=g[a].p) trn++;
            if (trn>cnt)
            cnt=trn, sol=g[a].p;
        }
        else
        if (g[a].p!=g[a].k) trn=1; else trn=0;
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);
    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }
    m=m*2;
    sort(g+1,g+1+m);
    int sol,cnt;

    for (a=1; a<=n; a++)
    if (sol>col[a])
    sol=col[a];
    cnt=0;

    int trn=1;
    for (a=1; a<=m; a++)
    {
        if (g[a].p==g[a-1].p && g[a].k>g[a-1].k)
        {
            trn++;
            if (trn>cnt)
            cnt=trn, sol=g[a].p;
        }
        else
        trn=1;
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);

    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }

    m=m*2;
    sort(g+1,g+1+m);
    int sol,cnt;
    sol=g[1].p;
    cnt=0;

    int boja,vr,last;
    boja=-1000;

    for (a=1; a<=m; a++)
    {
        if (boja==g[a].p)
        {
            if (g[a].k!=last && g[a].k!=boja)
            vr++, last=g[a].k;
            if (vr>cnt)
            cnt=vr, sol=boja;
        }
        else
        {
            boja=g[a].p;
            last=g[a].k;
            if (last!=boja) vr=1; else vr=0;
            if (vr>cnt)
            cnt=vr, sol=boja;
        }
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);
    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }
    m=m*2;
    sort(g+1,g+1+m);
    int sol,cnt;
    sol=0,cnt=0;
    int trn=1;
    for (a=1; a<=m; a++)
    {
        if (g[a].p==g[a-1].p)
        {
            if (g[a].k>g[a-1].k && g[a].p!=g[a].k) trn++;
            if (trn>cnt)
            cnt=trn, sol=g[a].p;
        }
        else
        trn=1;
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int col[100005];

struct grana
{
    int p,k;
    inline bool operator <(const grana &x) const
    {
        if (p!=x.p)
        return p<x.p;
        return k<x.k;
    }
};

grana g[200005];
int n,m,a;

int main()
{
    scanf("%d%d",&n,&m);
    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    int gnum=0;
    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        if (col[p]!=col[k])
        {
            gnum++;
            g[gnum].p=col[p];
            g[gnum].k=col[k];
            gnum++;
            g[gnum].p=col[k];
            g[gnum].k=col[p];
        }
    }
    sort(g+1,g+1+gnum);
    int sol,cnt;
    sol=1000000;

    for (a=1; a<=n; a++)
    if (sol>col[a])
    sol=col[a];
    cnt=0;

    int boja,last,vr;
    boja=-1000;
    for (a=1; a<=gnum; a++)
    {
        if (boja==g[a].p)
        {
            if (last!=g[a].k)
            vr++, last=g[a].k;
            if (vr>cnt)
            sol=boja,cnt=vr;
        }
        else
        {
            boja=g[a].p;
            last=g[a].k;
            vr=1;
            if (vr>cnt)
            sol=boja, cnt=vr;
        }
    }
    printf("%d\n",sol);
}


#include <cstdio>
#include <algorithm>

using namespace std;

int n,m;

struct grana
{
    int p,k;
    inline bool operator <(const grana &s) const
    {
        if (p!=s.p) return p<s.p;
        return k<s.k;
    }
};

int col[100005];
grana g[200005];
int a;

int main()
{
    scanf("%d%d",&n,&m);
    for (a=1; a<=n; a++)
    scanf("%d",&col[a]);

    for (a=1; a<=m; a++)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        g[a].p=col[p];
        g[a].k=col[k];
        g[a+m].p=col[k];
        g[a+m].k=col[p];
    }
    m=m*2;
    sort(g+1,g+1+m);
    /*
    for (a=1; a<=m; a++)
    printf("%d %d\n",g[a].p,g[a].k);
    */

    int sol,cnt;
    sol=0,cnt=0;
    int trn=1;
    for (a=1; a<=m; a++)
    {
        if (g[a].p==g[a-1].p && g[a].k>g[a-1].k)
        {
            if (g[a].k!=g[a].p) trn++;
            if (trn>cnt)
            cnt=trn, sol=g[a].p;
        }
        else
        trn=1;
    }
    printf("%d\n",sol);
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef int ll ;

set < ll > clr ;
vector < ll > e[100001] ;
ll c[100001] ;

void dfs( ll t, ll p )
{
        ll i, sz = (ll)e[t].size(), next ;
        for( i = 0 ; i < sz ; i++ )
        {
             next = e[t][i] ;
             if( next != p )
             {
                 if( c[t] == c[next] )
                   dfs( next, t ) ;
                 else
                   clr.insert( c[next] ) ;
             }
        }
}

main()
{
      ll n, m, i, j, a, b, mx = -1, mi, cur ;
      cin >> n >> m ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        e[a].push_back( b ) ;
        e[b].push_back( a ) ;
      }
      FOR1( i, n )
      {
            clr.clear() ;
            dfs(i, -1) ;
            if( (ll)clr.size() > mx || clr.size() == mx && c[i] < mi )
              mx = (ll)clr.size(), mi = c[i] ;
      }
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

main()
{
      ll n, m, i, j, a, b, c[10001], mx = -1, mi ;
      cin >> n >> m ;
      vector < ll > e[10001] ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        e[a].push_back( b ) ;
        e[b].push_back( a ) ;
      }
      FOR1( i, n )
      {
            set < ll > clr ;
            for( j = 0 ; j < (ll)e[i].size(); j++ )
              if( c[ e[i][j] ] != c[i] )
                clr.insert( c[ e[i][j] ] ) ;
            if( clr.size() > mx || clr.size() == mx && c[i] < mi )
              mx = clr.size(), mi = c[i] ;
      }
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

main()
{
      ll n, m, i, a, b, c[100001], mx = -1, mi ;
      cin >> n >> m ;
      set < ll > zz[100001] ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        if( c[a] != c[b] )
          zz[ c[a] ].insert( c[b] ) ;
        if( c[a] != c[b] )
          zz[ c[b] ].insert( c[a] ) ;
      }
      FOR1( i, 100000 )
        if( (ll)zz[ i ].size() > 0 )
          if( (ll)zz[ i ].size() > mx || (ll)zz[ i ].size() == mx && i < mi )
            mx = (ll)zz[ i ].size(), mi = i ;
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

main()
{
      ll n, m, i, j, a, b, c[10001], mx = -1, mi ;
      cin >> n >> m ;
      vector < ll > e[10001] ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        e[a].push_back( b ) ;
        e[b].push_back( a ) ;
      }
      FOR1( i, n )
      {
            set < ll > clr ;
            for( j = 0 ; j < (ll)e[i].size(); j++ )
              clr.insert( c[ e[i][j] ] ) ;
            if( clr.size() > mx || clr.size() == mx && c[i] < mi )
              mx = clr.size(), mi = c[i] ;
      }
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

main()
{
      ll n, m, i, a, b, mx = -1, mi, c[100001];
      set < ll > clr[100001] ;
      cin >> n >> m ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        if( c[a] != c[b] )
        {
            clr[ c[a] ].insert( c[b] ) ;
            clr[ c[b] ].insert( c[a] ) ;
        }
      }
      FOR1( i, n )
         if( (ll)clr[ c[i] ].size() > mx || clr[ c[i] ].size() == mx && c[i] < mi )
           mx = (ll)clr[ c[i] ].size(), mi = c[i] ;
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

set < ll > clr ;
vector < ll > e[100001] ;
ll c[100001] ;

void dfs( ll t, ll p )
{
        ll i, sz = (ll)e[t].size(), next ;
        for( i = 0 ; i < sz ; i++ )
        {
             next = e[t][i] ;
             if( next != p )
             {
                 if( c[t] == c[next] )
                   dfs( next, t ) ;
                 else
                   clr.insert( c[next] ) ;
             }
        }
}

main()
{
      ll n, m, i, j, a, b, mx = -1, mi, cur ;
      cin >> n >> m ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        e[a].push_back( b ) ;
        e[b].push_back( a ) ;
      }
      FOR1( i, n )
      {
            clr.clear() ;
            dfs(i, -1) ;
            if( clr.size() > mx || clr.size() == mx && c[i] < mi )
              mx = clr.size(), mi = c[i] ;
      }
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

main()
{
      ll n, m, i, a, b, c[10001], mx = 0, mi ;
      cin >> n >> m ;
      set < ll > zz[10001] ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        zz[ c[a] ].insert( c[b] ) ;
        zz[ c[b] ].insert( c[a] ) ;

        if( (ll)zz[ c[a] ].size() > mx )
          mx = (ll)zz[ c[a] ].size(), mi = c[a] ;

        if( (ll)zz[ c[b] ].size() > mx )
          mx = (ll)zz[ c[b] ].size(), mi = c[b] ;
      }
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

set < ll > clr ;
vector < ll > e[10001] ;
ll c[10001] ;

ll dfs( ll t, ll p )
{
        ll i, sz = (ll)e[c].size(), next ;
        for( i = 0 ; i < sz ; i++ )
        {
             next = e[c][i] ;
             if( next != p )
             {
                 if( c[i] == c[next]
             }
        }

main()
{
      ll n, m, i, j, a, b, mx = -1, mi, cur ;
      cin >> n >> m ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        e[a].push_back( b ) ;
        e[b].push_back( a ) ;
      }
      FOR1( i, n )
      {
            clr.clear() ;
            cur = dfs(i) ;
            for( j = 0 ; j < (ll)e[i].size(); j++ )
              if( c[ e[i][j] ] != c[i] )
                clr.insert( c[ e[i][j] ] ) ;
            if( clr.size() > mx || clr.size() == mx && c[i] < mi )
              mx = clr.size(), mi = c[i] ;
      }
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

main()
{
      ll n, m, i, a, b, c[10001], mx = -1, mi ;
      cin >> n >> m ;
      set < ll > zz[10001] ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        if( c[a] != c[b] )
          zz[ c[a] ].insert( c[b] ) ;
        if( c[a] != c[b] )
          zz[ c[b] ].insert( c[a] ) ;
      }
      FOR1( i, n )
        if( (ll)zz[ c[i] ].size() > mx || (ll)zz[ c[i] ].size() == mx && c[i] < mi )
          mx = (ll)zz[ c[i] ].size(), mi = c[i] ;
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

main()
{
      ll n, m, i, a, b, c[100001], mx = -1, mi ;
      cin >> n >> m ;
      set < ll > zz[100001] ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        if( c[a] != c[b] ) zz[ c[a] ].insert( c[b] ) ;
        if( c[a] != c[b] ) zz[ c[b] ].insert( c[a] ) ;
      }
      FOR1( i, 100000 )
        if( (ll)zz[ c[i] ].size() > mx || (ll)zz[ c[i] ].size() == mx && c[i] < mi )
          mx = (ll)zz[ c[i] ].size(), mi = c[i] ;
      cout << mi ;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

#define FOR0(i,n) for( i = 0 ; i < n ; i++ )
#define FOR1(i,n) for( i = 1 ; i <= n ; i++ )
#define sys_p system( "pause" )
#define End return 0
#define pb push_back
#define mp make_pair

ifstream Cin("input.txt");
ofstream Cout( "output.txt" );

typedef long long ll ;

main()
{
      ll n, m, i, a, b, c[100001], mx = -1, mi ;
      cin >> n >> m ;
      set < ll > zz[100001] ;
      FOR1( i, n )
        cin >> c[i] ;
      FOR1( i, m )
      {
        cin >> a >> b ;
        if( c[a] != c[b] ) zz[ c[a] ].insert( c[b] ) ;
        if( c[a] != c[b] ) zz[ c[b] ].insert( c[a] ) ;
      }
      FOR1( i, 100000 )
        if( (ll)zz[ c[i] ].size() > 0 )
          if( (ll)zz[ c[i] ].size() > mx || (ll)zz[ c[i] ].size() == mx && c[i] < mi )
            mx = (ll)zz[ c[i] ].size(), mi = c[i] ;
      cout << mi ;
}