q = int(input()) joutai = [0 for i in range(31)] s = {} ss = {} for i in range(q): a = list(map(int,input().split())) if a[0] == 1: if a[1] not in s: b = [] x = a[1] while x > 1: if x % 2 == 0: b.append("0") else: b.append("1") x //= 2 b.append("1") # print(b) for j in range(len(b)): if b[j] == "1": joutai[j] += 1 s[a[1]] = 1 elif a[0] == 2: if a[1] in s: b = [] x = a[1] while x > 1: if x % 2 == 0: b.append("0") else: b.append("1") x //= 2 b.append("1") # print(b) for j in range(len(b)): if b[j] == "1": joutai[j] -= 1 s.pop(a[1]) else: ans = 0 su = len(s) if su == 0: print(-1) continue for i in range(len(joutai)): if joutai[i] == su: ans += 2**i print(ans) # print(s,joutai)