#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int Q, cmd, x; cin >> Q; vector cnt(30); set S; while(Q--){ cin >> cmd; if(cmd <= 2)cin >> x; if(cmd == 1){ if(S.count(x))continue; S.insert(x); for(int i = 0; i < 30; i++){ if(x >> i & 1) cnt[i]++; } }else if(cmd == 2){ if(!S.count(x))continue; S.erase(x); for(int i = 0; i < 30; i++){ if(x >> i & 1) cnt[i]--; } }else{ if(S.empty()){ cout << -1 << '\n'; continue; } int ans = 0; for(int i = 0; i < 30; i++){ if(cnt[i] == S.size())ans |= 1 << i; } cout << ans << '\n'; } } }