Problem2332--Array Decrements

2332: Array Decrements

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

Kristina has two arrays aa and bb, each containing nn non-negative integers. She can perform the following operation on array aa any number of times:

  • apply a decrement to each non-zero element of the array, that is, replace the value of each element aiai such that ai>0ai>0 with the value ai−1ai−1 (1≤i≤n1≤i≤n). If aiai was 00, its value does not change.

Determine whether Kristina can get an array bb from an array aa in some number of operations (probably zero). In other words, can she make ai=biai=bi after some number of operations for each 1≤i≤n1≤i≤n?

For example, let n=4n=4a=[3,5,4,1]a=[3,5,4,1] and b=[1,3,2,0]b=[1,3,2,0]. In this case, she can apply the operation twice:

  • after the first application of the operation she gets a=[2,4,3,0]a=[2,4,3,0];
  • after the second use of the operation she gets a=[1,3,2,0]a=[1,3,2,0].

Thus, in two operations, she can get an array bb from an array aa.

Input

The first line of the input contains an integer tt (1≤t≤1041≤t≤104) —the number of test cases in the test.

The descriptions of the test cases follow.

The first line of each test case contains a single integer nn (1≤n≤5⋅1041≤n≤5⋅104).

The second line of each test case contains exactly nn non-negative integers a1,a2,…,ana1,a2,…,an (0≤ai≤1090≤ai≤109).

The third line of each test case contains exactly nn non-negative integers b1,b2,…,bnb1,b2,…,bn (0≤bi≤1090≤bi≤109).

It is guaranteed that the sum of nn values over all test cases in the test does not exceed 2⋅1052⋅105.

Output

For each test case, output on a separate line:

  • YES, if by doing some number of operations it is possible to get an array bb from an array aa;
  • NO otherwise.

Sample Input Copy

6
4
3 5 4 1
1 3 2 0
3
1 2 1
0 1 0
4
5 3 7 2
1 1 1 1
5
1 2 3 4 5
1 2 3 4 6
1
8
0
1
4
6

Sample Output Copy

YES
YES
NO
NO
YES
NO

Source/Category