#P9903. Equivalence
Equivalence
Equivalence
Problem Description
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 (). These two lines denotes edges with length on . The fourth line contains integers (), denoting edges on . It is guaranteed that .
Output
For each test case, the only line contains one integer denoting the answer.
Sample Input
1
5
1 5 2 2
0 2 3 1
5 5 5 1
Sample Output
1
Source
2023“钉耙编程”中国大学生算法设计超级联赛(10)