from collections import defaultdict d = defaultdict(int) q = int(input()) l = [0] *30 cnt = 0 for _ in range(q): qr = list(input().split()) if qr[0] == "1": x = int(qr[1]) if d[x] == 0: d[x] = 1 cnt += 1 i = 0 while x: if x & 1:l[i] += 1 x >>= 1 i += 1 elif qr[0] == "2": x = int(qr[1]) if d[x] : d[x] = 0 cnt -= 1 i = 0 while x: if x & 1:l[i] -= 1 x >>= 1 i += 1 else: if cnt == 0:print(-1) else: ans = 0 for i in range(30): if l[i] == cnt: ans += 2 ** i print(ans)