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>).
class graph:
    def __init__(self,n):
        self.n=n
        self.g=[[]for i in range(n)]
        self.t=0
        self.i=[-1 for i in range(n)]
        self.o=[-1 for i in range(n)]
        self.ft=[-1 for  i in range(2*(n))]
    def addedge(self,u,v):
        self.g[u].append(v)
        self.g[v].append(u)
    def subtree_dfs(self,v,p):
        self.i[v]=self.t
        self.ft[self.t]=v
        self.t+=1
        for i in self.g[v]:
            if i!=p:
                self.subtree_dfs(i,v)
        self.o[v]=self.t
        self.ft[self.t]=v
        self.t+=1
    def funct(self,v,k,c):
        d={}
        s=set()
        #print(self.g)
        #print(self.i)
        #print(self.o)
        #print(self.ft)
        falg=False
        for i in range(len(self.ft)):
            if self.ft[i]==v:
                falg=True
                j=i+1
                s.add(self.ft[i])
                while self.ft[j]!=v:
                    s.add(self.ft[j])
                    j+=1
            if falg==True:
                break
        #print(s)
        for i in s:
            d[c[i]]=d.get(c[i],0)+1
        #print(d)
        count=0
        for i in d:
            if d[i]>=k:
                count+=1
        print(count)
        
                
                
                
        
    
n,m=map(int,input().split())
c=[int(ele)for ele in input().split()]
g=graph(n)
for i in range(n-1):
    u,v=map(int,input().split())
    g.addedge(u-1,v-1)
g.subtree_dfs(0,-1)
for i in range(m):
    v,k=map(int,input().split())
    g.funct(v-1,k,c)

