#include using namespace std; using ll=long long; using pii=pair; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) int a[49]; signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); int q; cin >> q; set st; while(q--){ int op; cin >> op; if(op==1){ int x; cin >> x; if(st.count(x)) continue; st.insert(x); x=~x; for(int i=0; i<30; ++i) a[i]+=x>>i&1; } else if(op==2){ int x; cin >> x; if(!st.count(x)) continue; st.erase(x); x=~x; for(int i=0; i<30; ++i) a[i]-=x>>i&1; } else{ if(st.empty()) cout << "-1\n"; else{ int res=0; for(int i=0; i<30; ++i) if(!a[i]) res|=1<