You've got an undirected graph, consisting of *n* vertices and *m* edges. We will consider the graph's vertices numbered with integers from 1 to *n*. Each vertex of the graph has a color. The color of the *i*-th vertex is an integer *c*<sub class="lower-index">*i*</sub>.

Let's consider all vertices of the graph, that are painted some color *k*. Let's denote a set of such as *V*(*k*). Let's denote the value of the neighbouring color diversity for color *k* as the cardinality of the set *Q*(*k*) = {*c*<sub class="lower-index">*u*</sub> :  *c*<sub class="lower-index">*u*</sub> ≠ *k* and there is vertex *v* belonging to set *V*(*k*) such that nodes *v* and *u* are connected by an edge of the graph}.

Your task is to find such color *k*, which makes the cardinality of set *Q*(*k*) maximum. In other words, you want to find the color that has the most diverse neighbours. Please note, that you want to find such color *k*, that the graph has at least one vertex with such color.
The first line contains two space-separated integers *n*, *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">5</sup>) — the number of vertices end edges of the graph, correspondingly. The second line contains a sequence of integers *c*<sub class="lower-index">1</sub>, *c*<sub class="lower-index">2</sub>, ..., *c*<sub class="lower-index">*n*</sub> (1 ≤ *c*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">5</sup>) — the colors of the graph vertices. The numbers on the line are separated by spaces.

Next *m* lines contain the description of the edges: the *i*-th line contains two space-separated integers *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> ≤ *n*; *a*<sub class="lower-index">*i*</sub> ≠ *b*<sub class="lower-index">*i*</sub>) — the numbers of the vertices, connected by the *i*-th edge. 

It is guaranteed that the given graph has no self-loops or multiple edges.
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
from queue import PriorityQueue 
import sys
sys.setrecursionlimit(200010)
class Graph:
    def __init__(self, n):
        self.graph = defaultdict(lambda: [])
        self.vertices = n
        self.edges = 0
        self.toposorted = []

    def addEdge(self, a, b):  # tested
        self.graph[a].append(b)
        self.edges+=1

    def cycleUntill(self, visited, curr, parent):  # tested
        visited[curr] = True
        for i in self.graph[curr]:
            if(not visited[i]):
                if(self.cycleUntill(visited, i, curr)):
                    return True
            elif(i != parent):
                return True
        return False

    def cycle(self):  # tested
        n = self.vertices
        visited = [False]*(n+2)
        for i in range(1, n+1):
            if(not visited[i]):
                if(self.cycleUntill(visited, i, -1)):
                    return True
        return False

    def topologicalSort(self):#tested
        in_degree = [0]*(self.vertices+10)
        for i in self.graph:
            for j in self.graph[i]:
                in_degree[j] += 1
        queue = deque()
        for i in range(1,self.vertices+1):
            if in_degree[i] == 0:
                queue.append(i)
        cnt = 0
        while queue:
            u = queue.popleft()
            self.toposorted.append(u)
            for i in self.graph[u]:
                in_degree[i] -= 1
                if in_degree[i] == 0:
                    queue.append(i)
            cnt += 1
        if cnt != self.vertices:
            return False
        else:
            return True
    def connected(self):
        visited=[False]*(self.vertices +2)
        ans=[]
        for i in range(1,self.vertices+1):
            if(not visited[i]):
                comp=[]
                q=deque()
                visited[i]=True
                q.append(i)
                while(len(q)>0):
                    temp=q.popleft()
                    comp.append(temp)
                    for j in self.graph[temp]:
                        if(not visited[j]):
                            visited[j]=True
                            q.append(j)
                ans.append(comp)
        return ans

def find(curr):
    q=deque()
    q.append(1)
    while(len(q)>0):
        temp=q.pop()
        dfs.append(temp)
        for i in graph[temp]:
            q.append(i)
    for i in dfs[::-1]:
        if(parent[i]!=-1):
            subtree[parent[i]]+=subtree[i]

n,m=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
graph=defaultdict(lambda:[])
for _ in range(m):
    u,v=map(int,stdin.readline().split())
    graph[u].append(v)
    graph[v].append(u)
ans=[0]*(100010)
visited=[False]*(n+2)
for i in range(1,n+1):
    if(not visited[i]):
        visited[i]=True
        q=deque()
        q.append(i)
        while(len(q)>0):
            temp=q.pop()
            for j in graph[temp]:
                if(a[temp-1]!=a[j-1]):
                    ans[temp]+=1
                if(not visited[j]):
                    visited[j]=True 
                    q.append(j)
final=0
ma=0
for i in ans:
    if(i>ma):
        ma=i 
        final=a[i-1]
    elif(i==ma):
        final=min(final,a[i-1])
print(final)