CF2059A Milya and Two Arrays
Description
An array is called good if for any element $ x $ that appears in this array, it holds that $ x $ appears at least twice in this array. For example, the arrays $ [1, 2, 1, 1, 2] $ , $ [3, 3] $ , and $ [1, 2, 4, 1, 2, 4] $ are good, while the arrays $ [1] $ , $ [1, 2, 1] $ , and $ [2, 3, 4, 4] $ are not good.
Milya has two good arrays $ a $ and $ b $ of length $ n $ . She can rearrange the elements in array $ a $ in any way. After that, she obtains an array $ c $ of length $ n $ , where $ c_i = a_i + b_i $ ( $ 1 \le i \le n $ ).
Determine whether Milya can rearrange the elements in array $ a $ such that there are at least $ 3 $ distinct elements in array $ c $ .
Input Format
Each test consists of multiple test cases. The first line contains a single integer $ t $ ( $ 1 \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 $ n $ ( $ 3 \le n \le 50 $ ) — 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 $ .
Output Format
For each test case, output $ « $ YES $ » $ (without quotes) if it is possible to obtain at least $ 3 $ distinct elements in array $ c $ , and $ « $ NO $ » $ otherwise.
You can output each letter in any case (for example, $ « $ YES $ » $ , $ « $ Yes $ » $ , $ « $ yes $ » $ , $ « $ yEs $ » $ will be recognized as a positive answer).
Explanation/Hint
In the first test case, you can swap the second and third elements. Then the array $ a = [1, 1, 2, 2] $ , $ b = [1, 2, 1, 2] $ , and then $ c = [2, 3, 3, 4] $ .
In the second test case, you can leave the elements unchanged. Then $ c = [2, 3, 4, 4, 3, 2] $ .
In the third test case, the array $ a $ will not change from rearranging the elements in it. Then $ c = [2, 2, 2] $ , so the answer is $ « $ NO $ » $ .