q = int(input()) res = 1 << 30 seen = set() D = [0 for _ in range(30)] for _ in range(q): L = list(map(int, input().split())) if L[0] == 1: x = L[1] if x not in seen: seen.add(x) for i in range(30): D[i] += x % 2 x //= 2 elif L[0] == 2: x = L[1] if x in seen: seen.remove(x) for i in range(30): D[i] -= x % 2 x //= 2 else: if len(seen) == 0: print(-1) continue ans = 0 num = len(seen) for i in range(30): if D[i] == num: ans += 1 << i print(ans)