#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 1000000007; // constexpr int MOD = 998244353; constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int n; void out(string &ans) { while (ans.size() < n) ans += '3'; reverse(ALL(ans)); REP(i, n) cout << ans[i] << " \n"[i + 1 == n]; exit(0); } int main() { constexpr int B = 60; ll x, y; cin >> n >> x >> y; vector a(n); REP(i, n) cin >> a[i]; vector d(B); REP(i, B) d[i] = y >> i & 1; vector, string>> que; { vector bit(B); iota(ALL(bit), 0); que.emplace_back(bit, ""); } for (int i = n - 1; i >= 0; --i) { assert(que.size() <= 2); if (que.empty()) { cout << "-1\n"; return 0; } vector, string>> nx; for (auto it = que.begin(); it != que.end(); ++it) { vector &bit = it->first; string &ans = it->second; bool sw = true; for (int b : bit) { if (d[b] != (a[i] >> b & 1)) { sw = false; break; } } if (sw) out(ans); bool an = false, o = false; for (int b : bit) { if ((a[i] >> b & 1) && d[b] == 0) an = true; if (!(a[i] >> b & 1) && d[b] == 1) o = true; } if (an && o) continue; if (an) { ans += '1'; vector nx_bit; for (int b : bit) { if (!(!(a[i] >> b & 1) && d[b] == 0)) nx_bit.emplace_back(b); } if (nx_bit.empty()) out(ans); nx.emplace_back(nx_bit, ans); } else if (o) { ans += '2'; vector nx_bit; for (int b : bit) { if (!((a[i] >> b & 1) && d[b] == 1)) nx_bit.emplace_back(b); } if (nx_bit.empty()) out(ans); nx.emplace_back(nx_bit, ans); } else { int cnt[2] = {}; for (int b : bit) ++cnt[d[b]]; if (cnt[0] == bit.size()) { ans += '1'; out(ans); } else if (cnt[1] == bit.size()) { ans += '2'; out(ans); } else { { vector nx_bit; for (int b : bit) { if (!(!(a[i] >> b & 1) && d[b] == 0)) nx_bit.emplace_back(b); } assert(!nx_bit.empty()); nx.emplace_back(nx_bit, ans + '1'); } { vector nx_bit; for (int b : bit) { if (!((a[i] >> b & 1) && d[b] == 1)) nx_bit.emplace_back(b); } assert(!nx_bit.empty()); nx.emplace_back(nx_bit, ans + '2'); } } } } que.swap(nx); } for (auto it = que.begin(); it != que.end(); ++it) { vector &bit = it->first; string &ans = it->second; bool sw = true; for (int b : bit) { if (d[b] != (x >> b & 1)) { sw = false; break; } } if (sw) out(ans); } cout << "-1\n"; return 0; }