#include <bits/stdc++.h>
using namespace std;
#define _IO() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define int long long
int32_t main() {
_IO();
int t, casen = 1;
cin >> t;
while (t--) {
int n, x;
cin >> n >> x;
vector<int> s1(n);
vector<int> s2(n);
vector<int> s3(n);
for (int i = 0; i < n; i++) {
cin >> s1[i];
}
for (int i = 0; i < n; i++) {
cin >> s2[i];
}
for (int i = 0; i < n; i++) {
cin >> s3[i];
}
int knowledge = 0;
for (int i = 0; i < n; i++) {
if ((x | s1[i]) == x) {
knowledge |= s1[i];
} else {
break;
}
}
for (int i = 0; i < n; i++) {
if ((x | s2[i]) == x) {
knowledge |= s2[i];
} else {
break;
}
}
for (int i = 0; i < n; i++) {
if ((x | s3[i]) == x) {
knowledge |= s3[i];
} else {
break;
}
}
if (knowledge == x) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
1428B - Belted Rooms | 519B - A and B and Compilation Errors |
1152B - Neko Performs Cat Furrier Transform | 1411A - In-game Chat |
119A - Epic Game | 703A - Mishka and Game |
1504C - Balance the Bits | 988A - Diverse Team |
1312B - Bogosort | 1616B - Mirror in the String |
1660C - Get an Even String | 489B - BerSU Ball |
977C - Less or Equal | 1505C - Fibonacci Words |
1660A - Vasya and Coins | 1660E - Matrix and Shifts |
1293B - JOE is on TV | 1584A - Mathematical Addition |
1660B - Vlad and Candies | 1472C - Long Jumps |
1293D - Aroma's Search | 918A - Eleven |
1237A - Balanced Rating Changes | 1616A - Integer Diversity |
1627B - Not Sitting | 1663C - Pōja Verdon |
1497A - Meximization | 1633B - Minority |
688B - Lovely Palindromes | 66B - Petya and Countryside |