D. An Alternative Way
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output
You are given two arrays a and b, each of length n. You are allowed to perform the following operation on array a any number of times (including zero):
Determine whether you can make the array a equal to the array b by performing the operation any number of times.
Input
The first line contains a single integer t (1 \le t \le 10^4) — the number of test cases. Description of each test case follows.
The first line of each test case contains a single integer n (1 \le n \le 2\cdot10^5) — the length of the arrays a and b.
The second line of each test case contains n integers a_1, a_2, \ldots, a_n (1 \le a_i \le 10^9) — the elements of the array a.
The third line of each test case contains n integers b_1, b_2, \ldots, b_n (1 \le b_i \le 10^9) — the elements of the array b.
It is guaranteed that the sum of n over all test cases does not exceed 2\cdot10^5.
Output
For each test case, print "YES" if you can make array a equal to array b 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
Input
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
Output
YES
YES
NO
YES
NO
YES
NO
Note
For the first test case, arrays a and b are already equal.
For the second test case, let us choose l = 2 and r = 4. Now, we update the array a in the following manner:
Finally, we have array a = [1, 5, 4, 3] and array b = [1, 5, 4, 3].
For the third test case, it can be shown that it is impossible to make array a equal to array b.