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.
#Binary_Search

def Binary_Search_With_Index(color,colors,start,end):
    midle=int(end-(end-start)/2)
    if color==colors[midle]:
        return midle
    if color<colors[midle]:
        return Binary_Search_With_Index(color,colors,start,midle-1)
    return Binary_Search_With_Index(color,colors,midle+1,end)
    
def Binary_Search(color,colors):
    return Binary_Search_With_Index(color,colors,0,len(colors)-1)

#MergeSort_Edges
def Edges_CMP(a,b):
    if a[0]<b[0]:
        return -1
    if a[0]>b[0]:
        return 1
    if a[1]<b[1]:
        return -1
    if a[1]>b[1]:
        return 1
    return 0

def Merge_Edges(color_pos_edges,start,midle,end,aux):
    i=start
    j=midle+1
    k=start
    while i<=midle or j<= end:
        if i<=midle and (j>end or Edges_CMP(color_pos_edges[i],color_pos_edges[j])==-1):
            aux[k]=color_pos_edges[i]
            k+=1
            i+=1
        else:
            aux[k]=color_pos_edges[j]
            k+=1
            j+=1
    for p in range(start,end+1):
        color_pos_edges[p]=aux[p]

def MergeSort_With_Index_Edges(color_pos_edges,start,end,aux):
    if start==end:
        return
    midle=int(end-(end-start)/2)
    MergeSort_With_Index_Edges(color_pos_edges,start,midle,aux)
    MergeSort_With_Index_Edges(color_pos_edges,midle+1,end,aux)
    Merge_Edges(color_pos_edges,start,midle,end,aux)

def MergeSort_Edges(color_pos_edges):
    if len(color_pos_edges)<=1:
        return
    MergeSort_With_Index_Edges(color_pos_edges,0,len(color_pos_edges)-1,[[] for x in range(len(color_pos_edges))])

#MergeSort_Colors
def Merge_Colors(colors,start,midle,end,aux):
    i=start
    j=midle+1
    k=start
    while i<=midle or j<= end:
        if i<=midle and (j>end or colors[i]<colors[j]):
            aux[k]=colors[i]
            k+=1
            i+=1
        else:
            aux[k]=colors[j]
            k+=1
            j+=1
    for p in range(start,end+1):
        colors[p]=aux[p]

def MergeSort_With_Index_Colors(colors,start,end,aux):
    if start==end:
        return
    midle=int(end-(end-start)/2)
    MergeSort_With_Index_Colors(colors,start,midle,aux)
    MergeSort_With_Index_Colors(colors,midle+1,end,aux)
    Merge_Colors(colors,start,midle,end,aux)

def MergeSort_Colors(colors):
    if len(colors)<=1:
        return
    MergeSort_With_Index_Colors(colors,0,len(colors)-1,[0 for x in range(len(colors))])


#Recibiendo el numero de vertices y el numero de aristas
n_m_line=input()
n_m=n_m_line.split(" ")
n=int(n_m[0])
m=int(n_m[1])

#Recibiendo los colores de los vertices
colors_line=input()
colors_vertices=[int(x) for x in colors_line.split(" ")]

#Recibiendo las aristas
edges=[]
for i in range(m):
    edge_line=input()
    edge=[int(x) for x in edge_line.split(" ")]
    edges.append(edge)

color_edges=[]

#Obteniendo las aristas color para el nuevo grafo
for edge in edges:
    #Comprobando que los nodos tienen diferente color
    if colors_vertices[edge[0]-1]!=colors_vertices[edge[1]-1]:
        #obteniendo la arista color
        color_edge=[colors_vertices[edge[0]-1],colors_vertices[edge[1]-1]]
        #Agregandola al conjunto de arista color
        color_edges.append(color_edge)

MergeSort_Colors(colors_vertices)

colors=[]

actual_color=colors_vertices[0]
colors.append(actual_color)
for color in colors_vertices:
    if color!=actual_color:
        colors.append(color)
        actual_color=color

#Obteniendo aristas para la posicion de los colores
color_pos_edges=[]
for color_edge in color_edges:
    color_pos_edges.append([Binary_Search(color_edge[0],colors),Binary_Search(color_edge[1],colors)])

#Pasanado el menor vertice para la posicin cero en cada arista
for edge in color_pos_edges:
    if edge[0]>edge[1]:
        temp=edge[0]
        edge[0]=edge[1]
        edge[1]=temp 

#Ordenando las aristas segun los vertices que une
MergeSort_Edges(color_pos_edges)

degrees=[0 for x in range(len(colors))]
actual_edge=color_pos_edges[0]
degrees[actual_edge[0]]=degrees[actual_edge[1]]=1
for edge in color_pos_edges:
    if Edges_CMP(edge,actual_edge)!=0:
        degrees[edge[0]]+=1
        degrees[edge[1]]+=1
        actual_edge=edge.copy()

#Hallando los que tienen mayor degree
high=max(degrees)
pos_highs=[]
for i in range(len(degrees)):
    if high==degrees[i]:
        pos_highs.append(i)

color_highs=[]
for i in pos_highs:
    color_highs.append(colors[i])

result=min(color_highs)

print(result)

"""
5 6
4 2 5 2 4
1 2
2 3
3 1
5 3
5 4
3 4
"""