q = int(input()) xor = 0 s = set() bit = [0]*30 for _ in range(q): l = list(map(int,input().split())) if l[0] == 1: x = l[1] if x in s: continue s.add(x) for i in range(30): if x >> i & 1: bit[i] += 1 elif l[0] == 2: x = l[1] if x in s: s.discard(x) for i in range(30): if x >> i & 1: bit[i] -= 1 else: bitwise = 0 le = len(s) for i in range(30): if bit[i] == le: bitwise += 1 << i if le == 0: bitwise = -1 print(bitwise)