| Codeforces Round 1042 (Div. 3) |
|---|
| Finished |
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$$$.
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$$$.
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.
751 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 10
YES NO NO NO YES NO NO
In the first test case, you can perform the operations in the following order:
| Name |
|---|


