There have a tree ,which has n nodes, each node has a value w , the number of nodes whose value is w won't exceed 200.Then there are q queries, each has two integer u,v, we define a pair (x,y) is a good pair if w[x] = u, w[y] = v and x is on the path from root to y.
note: 1 is the root.
The first line contains one integer n .(1<=n<=10000)
Next line contains n integers w1,w2...wn, which means the values from 1 to n. (1<=wi<=10000)
Next n-1 line following, each line contain two integer a,b,(1<=a,b<=n), there is an edge between a and b.
Next is an integer q, (0<=q<=10000)
Then q lines following, each line contain two integer u,v.
for each query, print the number of good pairs.
4 1 2 3 4 1 2 1 3 2 4 3 2 2 1 3 1 4
0 1 1