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 *
import numpy as np
from collections import deque

def input():
	return stdin.readline()

def sumcal(id):
	sumtem = np.array([0]*N)
	sumtem[color[id-1]] = 1
	searched[id] = 1
	if adj[id] != 1 or id == 1:
		while len(route[id]) > 0:
			tem = route[id].popleft()
			if searched[tem] != 1:
				sumtem += sumcal(tem)
		sum_col[id] = sumtem
		return sumtem
	if adj[id] == 1 and id != 1:
		sum_col[id] = sumtem
		return sumtem


n, m = map(int, input().split())
global searched 
searched = [0] * (n+1)
color = [int(i) for i in input().split()]
global N
N = max(color) + 1
route = [deque([]) for i in range(n+1)]
adj = [0] * (n+1)

for i in range(n-1):
	x, y = map(int, input().split())
	route[x].append(y)
	adj[x] += 1
	route[y].append(x)
	adj[y] += 1

global sum_col 
sum_col = [np.array([0]*N)] * (n+1)
sumcal(1)

res = list()

for i in range(m):
	v, k = map(int, input().split())
	temp = sum_col[v]
	restem = sum(temp >= k)
	res.append(restem)

for i in range(len(res)):
	print(res[i])
