#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 main() { constexpr int B = 60; int n; ll x, y; cin >> n >> x >> y; vector a(n); REP(i, n) cin >> a[i]; vector, vector>> que; { vector bit(B), ans(n, 3); REP(i, B) bit[i] = y >> i & 1; que.emplace_back(bit, ans); } for (int i = n - 1; i >= 0; --i) { if (que.empty()) { cout << "-1\n"; return 0; } vector, vector>> nx; for (auto [bit, ans] : que) { bool sw = true; REP(b, B) sw &= bit[b] == -1 || bit[b] == (a[i] >> b & 1); int fixed = count(ALL(bit), -1); if (sw || fixed == B) { REP(i, n) cout << ans[i] << " \n"[i + 1 == n]; return 0; } bool an = false, o = false; REP(b, B) { if ((a[i] >> b & 1) && bit[b] == 0) an = true; if (!(a[i] >> b & 1) && bit[b] == 1) o = true; } if (an && o) continue; int cnt[2] = {}; REP(i, B) { if (bit[i] != -1) ++cnt[bit[i]]; } if (an) { REP(b, B) { if (!(a[i] >> b & 1) && bit[b] == 0) bit[b] = -1; } ans[i] = 1; nx.emplace_back(bit, ans); } else if (o) { REP(b, B) { if ((a[i] >> b & 1) && bit[b] == 1) bit[b] = -1; } ans[i] = 2; nx.emplace_back(bit, ans); } else if (cnt[0] + fixed == B) { REP(b, B) { if (!(a[i] >> b & 1) && bit[b] == 0) bit[b] = -1; } ans[i] = 1; nx.emplace_back(bit, ans); } else if (cnt[1] + fixed == B) { REP(b, B) { if ((a[i] >> b & 1) && bit[b] == 1) bit[b] = -1; } ans[i] = 2; nx.emplace_back(bit, ans); } else { { vector nx_bit = bit, nx_ans = ans; REP(b, B) { if (!(a[i] >> b & 1) && nx_bit[b] == 0) nx_bit[b] = -1; } nx_ans[i] = 1; nx.emplace_back(nx_bit, nx_ans); } { vector nx_bit = bit, nx_ans = ans; REP(b, B) { if ((a[i] >> b & 1) && bit[b] == 1) bit[b] = -1; } nx_ans[i] = 2; nx.emplace_back(nx_bit, nx_ans); } } } que.swap(nx); } for (auto [bit, ans] : que) { bool sw = true; REP(b, B) sw &= bit[b] == -1 || bit[b] == (x >> b & 1); if (sw) { REP(i, n) cout << ans[i] << " \n"[i + 1 == n]; return 0; } } cout << "-1\n"; return 0; }