You have a rooted tree consisting of *n* vertices. Each vertex of the tree has some color. We will assume that the tree vertices are numbered by integers from 1 to *n*. Then we represent the color of vertex *v* as *c*<sub class="lower-index">*v*</sub>. The tree root is a vertex with number 1.

In this problem you need to answer to *m* queries. Each query is described by two integers *v*<sub class="lower-index">*j*</sub>, *k*<sub class="lower-index">*j*</sub>. The answer to query *v*<sub class="lower-index">*j*</sub>, *k*<sub class="lower-index">*j*</sub> is the number of such colors of vertices *x*, that the subtree of vertex *v*<sub class="lower-index">*j*</sub> contains at least *k*<sub class="lower-index">*j*</sub> vertices of color *x*.

You can find the definition of a rooted tree by the following link: http://en.wikipedia.org/wiki/Tree_(graph_theory).
The first line contains two integers *n* and *m* (2 ≤ *n* ≤ 10<sup class="upper-index">5</sup>; 1 ≤ *m* ≤ 10<sup class="upper-index">5</sup>). The next 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 next *n* - 1 lines contain the edges of the tree. The *i*-th line contains the numbers *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 vertices connected by an edge of the tree.

Next *m* lines contain the queries. The *j*-th line contains two integers *v*<sub class="lower-index">*j*</sub>, *k*<sub class="lower-index">*j*</sub> (1 ≤ *v*<sub class="lower-index">*j*</sub> ≤ *n*; 1 ≤ *k*<sub class="lower-index">*j*</sub> ≤ 10<sup class="upper-index">5</sup>).
#get n and the num of queries
line = input()
pieces=line.split()
n= int(pieces[0])
q = int(pieces[1])#num of queries
#get colorList:a list of dicts {'p':color}
line2= input()
pieces2= line2.split()
colorList=[]
for i in range(len(pieces2)):
    colorList.append({i+1:pieces2[i]})
#get edgeList: a list of all the vertices' edges
edgeList=[]
for i in range(n):
    edgeList.append([])
for i in range(n-1):
    line = input()
    edge = line.split()
    edge1 = int(edge[0])
    edge2 = int(edge[1])
    edgeList[(edge1-1)].append(edge2)
    edgeList[(edge2-1)].append(edge1)
#print (edgeList)

parentList = []

for i in range(n):
    parentList.append(0)

preTraverse=[]
for i in range(n):
    preTraverse.append([])

preTraList=[]
preTraColor=[]
global cnt
cnt = -1
def DFS(p,parent):
    global cnt
    cnt +=1
    preTraList.append(p)
    preTraColor.append(int(colorList[p-1][p]))
    preTraverse[p-1].append(cnt)
    for v in edgeList[p-1]:
        if v!=parent:
            DFS(v,p)
            parentList[v-1]=p
    preTraverse[p-1].append(cnt)


#color=[]

def DFS2(p,parent):
    for v in edgeList[p-1]:
        if v!=parent:#v is p's son and vj's son(grandson...blah)
            #color.append(int(colorList[v-1][v]))
            colorCnt[int(colorList[v-1][v])-1] +=1
            DFS2(v,p)

DFS(1,0)

global lj,rj
def preDFS(p):
    for i in range(n):
        if preTraList[i] == vj:
            lj = preTraverse[i][0]
            rj = preTraverse[i][1]
    colorCnt=[]
    for i in range(n):
        colorCnt.append(0)
    for i in range(lj,rj+1):
        colorCnt[int(preTraColor[i]-1)] +=1
    count = 0
    for i in colorCnt:
        if i >= kj:
            count +=1
    print (count)


#print(parentList)




global kj
for i in range(q):
    lineQ= input()
    query = lineQ.split()
    vj = int(query[0]) #start vertax
    kj = int(query[1]) #least num same color
    preDFS(vj)
    """
    #color.append(int(colorList[vj-1][vj]))
    colorCnt=[]
    for i in range(n):
        colorCnt.append(0)
    colorCnt[int(colorList[vj-1][vj])-1] +=1
    #find the vertex's parent:parentList[vj-1]
    #DFS2(vj,parentList[vj-1])
    #print(color)
    #print(colorCnt)
    count = 0
    for i in colorCnt:
        if i >= kj:
            count +=1
    print (count)
"""
    """
print(preTraverse)
print(preTraList)
print(preTraColor)
"""