CF2059A.Milya and Two Arrays

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

Milya and Two Arrays

An array is called good if for any element xx that appears in this array, it holds that xx appears at least twice in this array. For example, the arrays [1,2,1,1,2][1, 2, 1, 1, 2], [3,3][3, 3], and [1,2,4,1,2,4][1, 2, 4, 1, 2, 4] are good, while the arrays [1][1], [1,2,1][1, 2, 1], and [2,3,4,4][2, 3, 4, 4] are not good.

Milya has two good arrays aa and bb of length nn. She can rearrange the elements in array aa in any way. After that, she obtains an array cc of length nn, where ci=ai+bic_i = a_i + b_i (1in1 \le i \le n).

Determine whether Milya can rearrange the elements in array aa such that there are at least 33 distinct elements in array cc.

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (3n503 \le n \le 50) — the length of the arrays aa and bb.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \le a_i \le 10^9) — the elements of the array aa.

The third line of each test case contains nn integers b1,b2,,bnb_1, b_2, \ldots, b_n (1bi1091 \le b_i \le 10^9) — the elements of the array bb.

Output

For each test case, output ««YES»» (without quotes) if it is possible to obtain at least 33 distinct elements in array cc, and ««NO»» otherwise.

You can output each letter in any case (for example, ««YES»», ««Yes»», ««yes»», ««yEs»» will be recognized as a positive answer).

Note

In the first test case, you can swap the second and third elements. Then the array a=[1,1,2,2]a = [1, 1, 2, 2], b=[1,2,1,2]b = [1, 2, 1, 2], and then c=[2,3,3,4]c = [2, 3, 3, 4].

In the second test case, you can leave the elements unchanged. Then c=[2,3,4,4,3,2]c = [2, 3, 4, 4, 3, 2].

In the third test case, the array aa will not change from rearranging the elements in it. Then c=[2,2,2]c = [2, 2, 2], so the answer is ««NO»».

Samples

5
4
1 2 1 2
1 2 1 2
6
1 2 3 3 2 1
1 1 1 1 1 1
3
1 1 1
1 1 1
6
1 52 52 3 1 3
59 4 3 59 3 4
4
100 1 100 1
2 2 2 2
YES
YES
NO
YES
NO

在线编程 IDE

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