def solve(q, qu): s = set() X = [] for v in qu: if v[0] == 1: s.add(v[1]) if v[0] == 2: s.discard(v[1]) if v[0] == 3: ans = 0 for v in s: ans |= v X.append(ans) return X q = int(input()) qu = [list(map(int,input().split())) for _ in range(q)] for v in solve(q, qu): print(v)