freq = [0] * 30 dic = set() Q = int(input()) cnt = 0 for _ in range(Q): query = input().split() if query[0] == "1": x = int(query[1]) if x not in dic: dic.add(x) for i in range(30): if x & (1 << i): freq[i] += 1 elif query[0] == "2": x = int(query[1]) if x in dic: dic.remove(x) for i in range(30): if x & (1 << i): freq[i] -= 1 else: x = len(dic) if x == 0: print(-1) continue ans = 0 for i in range(30): if freq[i] == x: ans += 1 << i print(ans)