#CF1107D. An Alternative Way 另一种方式
An Alternative Way 另一种方式
当前没有测试数据。
CF测试跳转:https://codeforces.com/contest/2241/problem/D
You are given two arrays and , each of length . You are allowed to perform the following operation on array any number of times (including zero):
- Choose two indices and such that ;
- For each index from to (both inclusive),
- Set if is odd.
- Set if is even.
Determine whether you can make the array equal to the array by performing the operation any number of times.
Input
The first line contains a single integer () — the number of test cases. Description of each test case follows.
The first line of each test case contains a single integer () — the length of the arrays and .
The second line of each test case contains integers () — the elements of the array .
The third line of each test case contains integers () — the elements of the array .
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print "YES" if you can make array equal to array and "NO" otherwise.
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).
Example
7
3
1 2 3
1 2 3
4
1 4 5 2
1 5 4 3
1
9
8
6
6 7 6 7 6 7
7 6 7 6 7 6
9
9 8 7 6 5 4 3 2 1
9 9 8 2 4 4 3 5 3
3
1 1 2
2 1 1
2
1 2
1 1
YES
YES
NO
YES
NO
YES
NO
Note
For the first test case, arrays and are already equal.
For the second test case, let us choose and . Now, we update the array in the following manner:
- For , we have , which is even. Hence, set .
- For , we have , which is odd. Hence, set .
- For , we have , which is even. Hence, set .
Finally, we have array and array .
For the third test case, it can be shown that it is impossible to make array equal to array .