Q=int(input()) s=set() res=[0]*30 for i in range(Q): q=list(map(int,input().split())) if q[0]==1: if q[1] not in s: s.add(q[1]) for j in range(30): if (q[1]>>j)&1: res[j]+=1 elif q[0]==2: if q[1] in s: s.discard(q[1]) for j in range(30): if (q[1]>>j)&1: res[j]-=1 else: if len(s)==0: print(-1) else: x=0 for a in res[::-1]: x<<=1 if a==len(s): x+=1 print(x)