#include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; int n; ll x, y; vector a; vector as_vec(ll x){ vector v(60); for(int i = 0; i < 60; i++){ if(((ll)1< &p, vector v){ // debug_value(i); if(i < 0) return false; auto u = as_vec(a[i]); bool ok_or = [&](){ for(int i = 0; i < 60; i++) { if(u[i] != 1) continue; if(v[i] == 0) return false; } return true; }(); bool ok_and = [&](){ for(int i = 0; i < 60; i++) { if(u[i] != 0) continue; if(v[i] == 1) return false; } return true; }(); if(ok_or && ok_and){ p[i] = 3; return true; } if(ok_or){ for(int i = 0; i < 60; i++){ if(v[i] == 1) v[i] = 2; } p[i] = 2; return dfs(i-1, p, v); } if(ok_and){ for(int i = 0; i < 60; i++){ if(v[i] == 0) v[i] = 2; } p[i] = 1; return dfs(i-1, p, v); } return false; } ll test(ll x, vector p){ for(int i = 0; i < n; i++){ int t = p[i]; if(t == 1) x &= a[i]; if(t == 2) x |= a[i]; if(t == 3) x = a[i]; } return x; } void get_vec(vector &a){ int n = a.size(); for(int i = 0; i < n; i++) cin >> a[i]; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> n >> x >> y; a.resize(n); get_vec(a); vector p(n, 1); vector v = as_vec(y); if(dfs(n-1, p, v)) { assert(test(x, p) == y); for(int x : p) cout << x << ' '; cout << endl; }else{ cout << -1 << endl; } }