Given a tree with N nodes with some non-negative value assigned to it. Lets say that the value of the ith node is wi. The beauty of a path between nodes u and v (denoted by B(u,v)) is described as the sum of values of all nodes that lie on the path excluding the nodes u and v. Note that B(u,u) is always zero for any valid node u. Ash is a weird guy. He only likes trees that have N∑u=1N∑v=1B(u,v)=0. In one operation Ash can change the value of any node to any non-negative value. Ash wants to find the minimum number of operations required so that he starts liking the given tree. But Ash does not have time to solve the problem as he is on his Pokemon adventure. So he needs your help in solving this problem.
Input Format:
The first line contains an integer T denoting the number of test cases. (1≤T≤10)
The following format is followed for each test case:
Next line contains a single integer N denoting the number of nodes in the tree. (1≤N≤105)
Next N−1 lines contains two space-separated integers u and v denoting that there is an edge between u and v. (1≤u,v≤N)
Next line contains N space-separated integers where the ith integers denotes wi. (0≤wi≤109)
Output Format:
For each test case, output the minimum number of operations required on a new line.
Following are the beauties of all paths:
B(1,2)=0, B(1,3)=0, B(2,3)=1.
We can change the value of node 1 and thus, beauties of all the paths will become 0. So, answer will be 1.