#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); ++i) int main() { int q; cin >> q; set s; vector cnt(30, vector(2, 0)); while (q--) { int t; cin >> t; if (t == 1) { int x; cin >> x; if (s.contains(x)) continue; s.insert(x); rep(i, 30) cnt[i][(x >> i) & 1]++; } else if (t == 2) { int x; cin >> x; if (!s.contains(x)) continue; s.erase(x); rep(i, 30) cnt[i][(x >> i) & 1]--; } else { if (s.empty()) { cout << -1 << endl; continue; } int res = 0; rep(i, 30) { if (cnt[i][0] > 0) continue; res |= 1 << i; } cout << res << endl; } } return 0; }