E. Adjacent XOR
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You're given an array $$$a$$$ of length $$$n$$$. For each index $$$i$$$ such that $$$1 \le i \lt n$$$, you can perform the following operation at most once:

You can choose indices and perform the operations in any sequential order.

Given another array $$$b$$$ of length $$$n$$$, determine if it is possible to transform $$$a$$$ to $$$b$$$.

Input

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.

The first line of each test case contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \lt 2^{30}$$$).

The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$0 \le b_i \lt 2^{30}$$$).

It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

Output

For each test case, output "YES" (quotes excluded) if $$$a$$$ can be transformed to $$$b$$$; otherwise, output "NO". You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Example
Input
7
5
1 2 3 4 5
3 2 7 1 5
3
0 0 1
1 0 1
3
0 0 1
0 0 0
4
0 0 1 2
1 3 3 2
6
1 1 4 5 1 4
0 5 4 5 5 4
3
0 1 2
2 3 2
2
10 10
11 10
Output
YES
NO
NO
NO
YES
NO
NO
Note

In the first test case, you can perform the operations in the following order:

  1. Choose index $$$i=3$$$ and assign $$$a_3 := a_3 \oplus a_4 = 7$$$, and $$$a$$$ becomes $$$[1, 2, 7, 4, 5]$$$.
  2. Choose index $$$i=4$$$ and assign $$$a_4 := a_4 \oplus a_5 = 1$$$, and $$$a$$$ becomes $$$[1, 2, 7, 1, 5]$$$.
  3. Choose index $$$i=1$$$ and assign $$$a_1 := a_1 \oplus a_2 = 3$$$, and $$$a$$$ becomes $$$[3, 2, 7, 1, 5]$$$.