Weak Pair

http://acm.hdu.edu.cn/showproblem.php?pid=5877

Problem Description

You are given a rooted tree of NN nodes, labeled from 1 to NN. To the ith node a non-negative value ai is assigned.An ordered pair of nodes (u,v)(u,v) is said to be weak if
(1) uu is an ancestor of vv (Note: In this problem a node uu is not considered an ancestor of itself);
(2) au×avk{a_u×a_v}\leq{k}.

Can you find the number of weak pairs in the tree?

Input

There are multiple cases in the data set.
The first line of input contains an integer TT denoting number of test cases.
For each case, the first line contains two space-separated integers, NN and kk, respectively.
The second line contains NN space-separated integers, denoting a1a_1 to aNa_N.
Each of the subsequent lines contains two space-separated integers defining an edge connecting nodes uu and vv , where node uu is the parent of node vv.

Constrains:

1N1051≤N≤10^{5}

0ai1090≤a_i≤10^{9}

0k10180≤k≤10^{18}

Output

For each test case, print a single integer on a single line denoting the number of weak pairs in the tree.

Sample Input

1
2 3
1 2
1 2

Sample Output

1

题目:

给你一棵有NN个节点的树,并且每个节点有对应的一个值,现在定义一个叫WEAK PAIR的东西(u,v),当满足一下条件是(u,v)就是WEAK PAIR:
1.u是v的祖先
2.