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>).
from sys import *
from collections import deque as dq

def input():
    return stdin.readline()

def f(a,b):
    if a==b:
        return 1
    return 0

n,m=list(map(int,input().split()))
trees={i:[] for i in range(n)}
tree={i:[] for i in range(n)}
c=list(map(int,input().split()))
cc=set(c)
for i in range(n-1):
    a,b=list(map(lambda x:int(x)-1,input().split()))
    trees[a].append(b)
    trees[b].append(a)

#print(trees)

colors={i:{j:0 for j in cc} for i in range(n)}
height=[]
temp=[[0,-1]]
while temp:
    newtemp=[]
    for a,fa in temp:
        for j in trees[a]:
            if j!=fa:
                tree[a].append(j)
                newtemp.append([j,a])                          
    height.append([i[0] for i in temp])
    temp=newtemp


#print(tree)
#print(height)

bottom=height.pop()
for i in bottom:
    colors[i][c[i]]=1
while height:
    bottom=height.pop()
    for i in bottom:
        for k in cc:
            colors[i][k]=sum([colors[j][k] for j in tree[i]])+f(c[i],k)

ans=[0 for i in range(m)]
for i in range(m):
    a,b=list(map(lambda x:int(x)-1,input().split()))
    ans[i]=0    
    for j in cc:
        if colors[a][j]>b:
            ans[i]+=1
#print(colors)            
            
print('\n'.join([str(i) for i in ans]))