CF1842B.Tenzing and Books

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Tenzing received 3n3n books from his fans. The books are arranged in 33 stacks with nn books in each stack. Each book has a non-negative integer difficulty rating.

Tenzing wants to read some (possibly zero) books. At first, his knowledge is 00 .

To read the books, Tenzing will choose a non-empty stack, read the book on the top of the stack, and then discard the book. If Tenzing's knowledge is currently uu , then his knowledge will become uvu|v after reading a book with difficulty rating vv . Here | denotes the bitwise OR operation. Note that Tenzing can stop reading books whenever he wants.

Tenzing's favourite number is xx . Can you help Tenzing check if it is possible for his knowledge to become xx ?

输入格式

Each test contains multiple test cases. The first line of input contains a single integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases. The description of test cases follows.

The first line of each test case contains two integers nn and xx ( 1n1051 \leq n \leq 10^5 , 0x1090 \leq x \leq 10^9 ) — the number of books in each stack and Tenzing's favourite number.

The second line of each test case contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n ( 0ai1090 \leq a_i \leq 10^9 ) — the difficulty rating of the books in the first stack, from top to bottom.

The third line of each test case contains nn integers b1,b2,,bnb_1,b_2,\ldots,b_n ( 0bi1090 \leq b_i \leq 10^9 ) — the difficulty rating of the books in the second stack, from top to bottom.

The fourth line of each test case contains nn integers c1,c2,,cnc_1,c_2,\ldots,c_n ( 0ci1090 \leq c_i \leq 10^9 ) — the difficulty rating of the books in the third stack, from top to bottom.

It is guaranteed that the sum of nn does not exceed 10510^5 .

输出格式

For each test case, output "Yes" (without quotes) if Tenzing can make his knowledge equal to xx , and "No" (without quotes) otherwise.

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

输入输出样例

  • 输入#1

    3
    5 7
    1 2 3 4 5
    5 4 3 2 1
    1 3 5 7 9
    5 2
    3 2 3 4 5
    5 4 3 2 1
    3 3 5 7 9
    3 0
    1 2 3
    3 2 1
    2 2 2

    输出#1

    Yes
    No
    Yes

说明/提示

For the first test case, Tenzing can read the following 44 books:

  • read the book with difficulty rating 11 on the top of the first stack. Tenzing's knowledge changes to 01=10|1=1 .
  • read the book with difficulty rating 11 on the top of the third stack. Tenzing's knowledge changes to 11=11|1=1 .
  • read the book with difficulty rating 22 on the top of the first stack. Tenzing's knowledge changes to 12=31|2=3 .
  • read the book with difficulty rating 55 on the top of the second stack. Tenzing's knowledge changes to 35=73|5=7 .

After reading all books, Tenzing's knowledge is 77 .

For the third test case, Tenzing can read 00 books to make his final knowledge equals to 00 .

首页