q = int(input()) now = [0]*(35) s = set() cnt = 0 for i in range(q): l = list(map(int,input().split())) t = l[0] if t == 1: x = l[1] if x in s: continue else: s.add(x) for j in range(35): if (x>>j) & 1: now[j] += 1 cnt += 1 elif t == 2: x = l[1] if x in s: s.discard(x) for j in range(35): if (x>>j) & 1: now[j] -= 1 cnt -= 1 else: if cnt == 0: print(-1) continue ans = 0 for j in range(35): if now[j] == cnt: ans += 1 << j print(ans)