def fast_bitwise_and(S): if len(S) == 0: return -1 MAX_BITS = 32 count = [0] * MAX_BITS for num in S: for bit in range(MAX_BITS): if num & (1 << bit): count[bit] += 1 result = 0 for bit in range(MAX_BITS): if count[bit] == len(S): result |= (1 << bit) return result Q = int(input().strip()) S = set() for _ in range(Q): query = list(map(int, input().strip().split())) if query[0] == 1: S.add(query[1]) elif query[0] == 2: if query[1] in S: S.remove(query[1]) elif query[0] == 3: print(fast_bitwise_and(S))