logo AlgoBeat OnlineJudge
登录 注册

#214597. [ICPC 2025 Xi'an R] Killing Bits

内存限制:512 MiB 时间限制:4000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given two arrays and , both consisting of non-negative integers. You can perform the following operation on the array an arbitrary number of times (possibly, zero):

  • First, you select a permutation of ;
  • Then, for each , you set to . Here, denotes the bitwise AND operation.

You have to determine whether it is possible to transform into .

输入格式

The input consists of multiple test cases. The first line contains an integer (), the number of test cases. For each test case:

  • The first line contains a single integer (), which is the length of arrays and .
  • The second line contains integers (), which are the elements of .
  • The third line contains integers (), which are the elements of .

It is guaranteed that the sum of over all test cases does not exceed .

输出格式

For each test case, print in a single line if it is possible to transform into . Otherwise, print .

You can output the answer in any case (upper or lower). For example, the strings , , , and will be recognized as positive responses.

样例

样例输入 1

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

样例输出 1

No
Yes
Yes
No

数据范围与提示

In the first test case, we need to use at least one operation to transform into . Note that is always because . However, , so it is impossible to make , no matter how the permutations are selected during the operations.

In the second test case, you can select . After this operation, is transformed into .

In the third test case, , so we do not need any operations.