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>).
__author__ = 'Utena'
from sys import *
def input():
    return stdin.readline()
N = 100005
dfs_order_color=[0]*N
dfs_st=[0]*N
dfs_ed=[0]*N
sz=[0]*N
cnt=[0]*N
sum=[0]*N
youngest_child=[0]*N
conn=[[]for i in range(2*N)]
conn_child=[0]*(2*N)
next_query=[0]*N
dfs=0
def connect(x,y):
    conn[x].append(y)
def size(x,f):
    sz[x] = 1
    for w in conn[x]:
        if w!=f:
            size(w,x)
            sz[x]+=sz[w]
def ins(x):
    for i in range(dfs_st[x],dfs_ed[x]+1):
        cnt[dfs_order_color[i]]+=1
        sum[cnt[dfs_order_color[i]]]+=1
def delete(x):
    for i in range(dfs_st[x],dfs_ed[x]+1):
        sum[cnt[dfs_order_color[i]]]-=1
        cnt[dfs_order_color[i]]-=1
def solve(x,f):
    global dfs
    dfs+=1
    dfs_st[x]=dfs
    dfs_order_color[dfs]=color[x]
    mx=0
    mf=0
    for w in conn[x]:
        if w!=f:
            if sz[w]>mx:
                mx=sz[w]
                mf=w
    for w in conn[x]:
        if w!=f and w!=mf:
            solve(w,x)
            delete(w)
    if mx:
        solve(mf,x)
    for w in conn[x]:
        if w!=f and w!=mf:
            ins(w)
    cnt[color[x]]+=1
    sum[cnt[color[x]]]+=1
    w=now_q[x]
    while w>0:
        ans[w]=sum[ks[w]]
        w=next_query[w]
    dfs_ed[x]=dfs
n,m=map(int,input().split())
color=[0]+list(map(int,input().split()))
qs=[0]
ks=[0]
now_q=[0]*N
ans=[0]+[0]*m
for i in range(n-1):
    x,y=map(int,input().split())
    connect(x,y)
    connect(y,x)
for i in range(1,m+1):
    x,k=map(int,input().split())
    qs.append(x)
    ks.append(k)
    next_query[i]=now_q[x]
    now_q[x]=i
size(1,0)
solve(1,0)
print('\n'.join(map(str,ans[1:])))