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 copy import deepcopy

def read():
    return [int(num) for num in input().split()]


N, M = read()
# print(N, M)
C = [0] + read()
# print(C)
Max = max(C)
# print(Max)
Adj = [None] * (N + 1)
E = []


class Graph:
    v = 0
    nxt = None

    def __init__(self, _v, _nxt):
        self.v = _v
        self.nxt = _nxt


def addedge(u, v):
    E.append(Graph(v, Adj[u]))
    Adj[u] = E[-1]


for i in range(N - 1):
    u, v = read()
    addedge(u, v)

A = [[] for _ in range(0, N + 1)]
Q = [0]
for i in range(1, M + 1):
    tmp = read()
    Q.append(tmp[1])
    A[tmp[0]].append(i)
    # print(tmp)
    # print(tmp[0])
    # print(A[tmp[0]])
    # print("! {} {}".format(tmp[0], i))
    # print(A[5])
    # print(Q[-1])

# print("finished")
Siz = [0] * (N + 1)
Big = [0] * (N + 1)
T = [0] * (N + 1)


def lowbit(x):
    return x & (-x)


def add(p, d):
    while p <= N:
        T[p] += d
        p += lowbit(p)


def query(p):
    ret = 0
    while p > 0:
        ret += T[p]
        p -= lowbit(p)
    return ret


def dfs1(u, f):
    Siz[u] = 1
    j = Adj[u]
    while j is not None:
        v = j.v
        if v != f:
            dfs1(v, u)
            Siz[u] += Siz[v]
            if Siz[v] > Siz[Big[u]]:
                Big[u] = v
        j = j.nxt


Ban = 0
Cnt = [0] * (Max + 1)


def update(u, f, val):
    if val == 1:
        if Cnt[C[u]] != 0:
            add(Cnt[C[u]], -1)
        Cnt[C[u]] += 1
        add(Cnt[C[u]], 1)
    else:
        add(Cnt[C[u]], -1)
        Cnt[C[u]] -= 1
        if Cnt[C[u]] != 0:
            add(Cnt[C[u]], 1)
    j = Adj[u]
    while j is not None:
        v = j.v
        if v != f and v != Ban:
            update(v, u, val)
        j = j.nxt


Ans = [0] * (M + 1)


def dfs2(u, f, kep):
    # print(u)
    j = Adj[u]
    while j is not None:
        v = j.v
        if v != f and v != Big[u]:
            dfs2(v, u, False)
        j = j.nxt
    if Big[u] != 0:
        dfs2(Big[u], u, True)
    global Ban
    Ban = Big[u]
    # print('[' + str(Ban) + ']')
    update(u, f, 1)
    for i in A[u]:
        global Ans
        Ans[i] = query(N) - query(Q[i] - 1)
        # if u == 5:
            # print("\t {} {}: {}".format(i, u, Ans[i]))
    if not kep:
        Ban = 0
        update(u, f, -1)


dfs1(1, -1)
# print("dfs1 finished")
# print(Siz)
dfs2(1, -1, False)
# print("dfs2 finished")

for i in range(1, M + 1):
    print(Ans[i], end = " ")
