def resolve(): q = int(input()) s = set() cnt = [0] * 30 for _ in range(q): query = tuple(map(int, input().split())) if query[0] == 1: x = query[1] if x not in s: s.add(x) i = 0 while x: if x & 1: cnt[i] += 1 x >>= 1 i += 1 elif query[0] == 2: x = query[1] if x in s: s.remove(x) i = 0 while x: if x & 1: cnt[i] -= 1 x >>= 1 i += 1 else: if s: print(sum(1 << i for i, x in enumerate(cnt) if x == len(s))) else: print(-1) # print(s, cnt) if __name__ == "__main__": resolve()