#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int q; cin>>q; vector c(30,0); set S; rep(_,q){ int t; cin>>t; if(t==1){ int x; cin>>x; if(S.count(x))continue; S.insert(x); rep(j,30){ if((x>>j)&1)c[j]++; } } if(t==2){ int x; cin>>x; if(!S.count(x))continue; S.erase(x); rep(j,30){ if((x>>j)&1)c[j]--; } } if(t==3){ int ans = 0; if(S.size()==0)ans = -1; else{ rep(j,30){ if(c[j]==S.size())ans |= 1<