CF1584C.Two Arrays

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Two Arrays

You are given two arrays of integers a1,a2,,ana_1, a_2, \ldots, a_n and b1,b2,,bnb_1, b_2, \ldots, b_n.

Let's define a transformation of the array aa:

  1. Choose any non-negative integer kk such that 0kn0 \le k \le n.
  2. Choose kk distinct array indices 1i1<i2<<ikn1 \le i_1 \lt i_2 \lt \ldots \lt i_k \le n.
  3. Add 11 to each of ai1,ai2,,aika_{i_1}, a_{i_2}, \ldots, a_{i_k}, all other elements of array aa remain unchanged.
  4. Permute the elements of array aa in any order.

Is it possible to perform some transformation of the array aa exactly once, so that the resulting array is equal to bb?

Input

The first line contains a single integer tt (1t1001 \le t \le 100) — the number of test cases. Descriptions of test cases follow.

The first line of each test case contains a single integer nn (1n1001 \le n \le 100) — the size of arrays aa and bb.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (100ai100-100 \le a_i \le 100).

The third line of each test case contains nn integers b1,b2,,bnb_1, b_2, \ldots, b_n (100bi100-100 \le b_i \le 100).

Output

For each test case, print "YES" (without quotes) if it is possible to perform a transformation of the array aa, so that the resulting array is equal to bb. Print "NO" (without quotes) otherwise.

You can print each letter in any case (upper or lower).

Note

In the first test case, we can make the following transformation:

  • Choose k=2k = 2.
  • Choose i1=1i_1 = 1, i2=2i_2 = 2.
  • Add 11 to a1a_1 and a2a_2. The resulting array is [0,2,0][0, 2, 0].
  • Swap the elements on the second and third positions.

In the second test case there is no suitable transformation.

In the third test case we choose k=0k = 0 and do not change the order of elements.

Samples

3
3
-1 1 0
0 0 2
1
0
2
5
1 2 3 4 5
1 2 3 4 5
YES
NO
YES

在线编程 IDE

建议全屏模式获得最佳体验