#include #define rep(i, a, n) for(int i = a; i < (n); i++) using namespace std; using ll = long long; using P = pair; const int INF = 1001001001; const ll LINF = 1001002003004005006ll; //const int mod = 1000000007; //const int mod = 998244353; int main() { int q; cin >> q; set st; vector bit(30); rep(qi, 0, q) { ll t, x; cin >> t; if (t == 1) { cin >> x; if (st.count(x)) continue; st.insert(x); rep(i, 0, 30) if (!(x>>i&1)) bit[i]++; } else if (t == 2) { cin >> x; if (st.count(x)) { st.erase(x); rep(i, 0, 30) if (!(x>>i&1)) bit[i]--; } } else { if (!st.size()) cout << -1 << endl; else { ll tmp = 1; ll ans = 0; rep(i, 0, 30) { if (!bit[i]) ans += tmp; tmp *= 2; } cout << ans << endl; } } } return 0; }