#SL2310E. Equivalence
Equivalence
Equivalence
You are given two trees , both with vertices. The lengths of edges of are given. The length of each edge is non-negative.
A tree with vertices is good, if there is a way to assign each edge on with a length which satisfies the following condition:
- For each pair satisfying , the distances of and on and are the same.
You can perform the following operation on : select an edge on and replace its length with any non-negative integer.
Find the minimum number of operations to make good.
Input
The first line of input contains a single integer , denoting the number of test cases.
For each test case, the first line contains one integer .
The second line contains integers .
The third line contains integers $val_2, val_3, \dots,val_n \: (0 \leq val_i \leq 10^9)$
These two lines denotes edges with weight on .
The fourth line contains integers , denoting edges on .
Output
For each test case, the only line contains one integer denoting the answer.
Example
1
5
1 5 2 2
0 2 3 1
5 5 5 1
1