#include using namespace std; vector dfs(vector A, int X, int p){ if (A.empty()){ return A; } if (p == -1){ if (A.size() == 1){ return A; } else { return vector(0); } } vector B0, B1; for (int x : A){ if ((x >> p & 1) == 0){ B0.push_back(x); } else { B1.push_back(x); } } if ((X >> p & 1) == 0){ vector ans0 = dfs(B0, X, p - 1); vector ans1 = dfs(B1, X, p - 1); if (!B0.empty() && ans0.empty()){ return vector(0); } if (!B1.empty() && ans1.empty()){ return vector(0); } for (int x : ans1){ ans0.push_back(x); } int cnt = ans0.size(); bool ok = true; int X2 = X & ((1 << (p + 1)) - 1); for (int i = 0; i < cnt - 1; i++){ if (ans0[i] >= (ans0[i + 1] ^ X2)){ ok = false; } if ((ans0[i] ^ X2) >= ans0[i + 1]){ ok = false; } } if (!ok){ return vector(0); } return ans0; } else { int cnt0 = B0.size(); int cnt1 = B1.size(); if (abs(cnt0 - cnt1) >= 2){ return vector(0); } vector C0 = dfs(B0, X, p - 1); vector C1 = dfs(B1, X, p - 1); if (!B0.empty() && C0.empty()){ return vector(0); } if (!B1.empty() && C1.empty()){ return vector(0); } vector ans1, ans2; if (cnt0 > cnt1){ for (int i = 0; i < cnt1; i++){ ans1.push_back(C0[i]); ans1.push_back(C1[i]); } ans1.push_back(C0[cnt1]); } else if (cnt1 > cnt0){ for (int i = 0; i < cnt0; i++){ ans1.push_back(C1[i]); ans1.push_back(C0[i]); } ans1.push_back(C1[cnt0]); } else { for (int i = 0; i < cnt0; i++){ ans1.push_back(C0[i]); ans1.push_back(C1[i]); ans2.push_back(C1[i]); ans2.push_back(C0[i]); } } int cnt = cnt0 + cnt1; bool ok1 = true, ok2 = true; int X2 = X & ((1 << (p + 1)) - 1); for (int i = 0; i < cnt - 1; i++){ if (ans1[i] >= (ans1[i + 1] ^ X2)){ ok1 = false; } if ((ans1[i] ^ X2) >= ans1[i + 1]){ ok1 = false; } if (!ans2.empty()){ if (ans2[i] >= (ans2[i + 1] ^ X2)){ ok2 = false; } if ((ans2[i] ^ X2) >= ans2[i + 1]){ ok2 = false; } } } if (!ans1.empty() && ok1){ return ans1; } else if (!ans2.empty() && ok2){ return ans2; } else { return vector(0); } } } int main(){ int N, X; cin >> N >> X; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector res = dfs(A, X, 29); if (!res.empty()){ cout << "Yes" << endl; } else { cout << "No" << endl; } }