Problem E

Statement
Copy Copied
E. Adjacent XORtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output  You're given an array $$$a$$$ of length $$$n$$$. For each index $$$i$$$ such that $$$1 \le i < n$$$, you can perform the following operation at most once:  Assign $$$a_i := a_i \oplus a_{i+1}$$$, where $$$\oplus$$$ denotes the bitwise XOR operation. . 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$$$.InputEach 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 < 2^{30}$$$).The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$0 \le b_i < 2^{30}$$$).It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$. OutputFor 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.ExampleInput751 2 3 4 53 2 7 1 530 0 11 0 130 0 10 0 040 0 1 21 3 3 261 1 4 5 1 40 5 4 5 5 430 1 22 3 2210 1011 10OutputYES
NO
NO
NO
YES
NO
NO
NoteIn the first test case, you can perform the operations in the following order:  Choose index $$$i=3$$$ and assign $$$a_3 := a_3 \oplus a_4 = 7$$$, and $$$a$$$ becomes $$$[1, 2, 7, 4, 5]$$$.  Choose index $$$i=4$$$ and assign $$$a_4 := a_4 \oplus a_5 = 1$$$, and $$$a$$$ becomes $$$[1, 2, 7, 1, 5]$$$.  Choose index $$$i=1$$$ and assign $$$a_1 := a_1 \oplus a_2 = 3$$$, and $$$a$$$ becomes $$$[3, 2, 7, 1, 5]$$$.