#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; int main() { int Q; cin >> Q; vector bit(30, 0); set st; while (Q--) { int t; cin >> t; if (t == 1) { int x; cin >> x; if (!st.count(x)) { st.insert(x); for (int i = 0; i < 30; i++) { if (1 & (x >> i)) { bit[i]++; } } } } else if (t == 2) { int x; cin >> x; if (st.count(x)) { st.erase(x); for (int i = 0; i < 30; i++) { if (1 & (x >> i)) { bit[i]--; } } } } else { if (st.size() == 0) cout << -1 << endl; else { int ans = 0; for (int i = 0; i < 30; i++) { if (bit[i] == st.size()) ans += 1 << i; } cout << ans << endl; } } } }