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>).
def add(a,x,d):
	i=x
	while i<=n:
		if not i in a: a[i]=0
		a[i]+=d
		i+=i&-i
def query(a,x):
	i=x
	s=0
	while i>0:
		if i in a: s+=a[i]
		i-=i&-i
	return s
def merge(l):
	up={}
	for b in l[1:]:
		for c,y in b[0].items():
			y0=(l[0][0][c] if c in l[0][0] else 0)
			if not c in up: up[c]=y0
			l[0][0][c]=y0+y
	for c in up:
		if up[c]: add(l[0][1],up[c],-1)
		add(l[0][1],l[0][0][c],1)
def dfs(x):
	u[x]=1
	tmp=({c[x]:1},{})
	l=[tmp]
	for y in g[x]:
		if not u[y]:
			l.append(dfs(y))
	if len(l)==1: add(tmp[1],1,1)
	else:
		maxc=max(map(lambda x: len(x[0]),l[1:]))
		ind=list(filter(lambda x: len(l[x][0])==maxc,range(1,len(l))))[0]
		l[0],l[ind]=l[ind],l[0]
		merge(l)
	l=l[0]
	for k,i in q[x]:
		ans[i]=len(l[0])-query(l[1],min(k-1,n))
	return l
n,m=map(int,input().split())
c=list(map(int,input().split()))
g=[[] for i in range(n)]
for i in range(n-1):
	a,b=map(int,input().split())
	a,b=a-1,b-1
	g[a].append(b)
	g[b].append(a)
ans=[0 for i in range(m)]
q=[[] for i in range(n)]
u=[0 for i in range(n)]
for i in range(m):
	v,k=map(int,input().split())
	q[v-1].append((k,i))
dfs(0)
print('\n'.join(map(str,ans)))
