#================================================== def send(i,k): print(i,k, flush=True) def recieve(): i,k=map(int,input().split()) return i,k def phase(): return int(input()) def choice(turn): print(turn, flush=True) def bit(x,k): return (x>>k)&1 #================================================== def solve(): N=int(input()) A=[0]+list(map(int,input().split())) grundy=0; B=17 S=[set([i for i in range(1,N+1) if bit(A[i],t)]) for t in range(B)] for a in A[1:]: grundy^=a turn=1 if grundy else 0 choice(turn) while True: if turn: msb=grundy.bit_length()-1 i=S[msb].pop() a=A[i] b=grundy^A[i] k=A[i]-b send(i,k) else: i,k=recieve() for t in range(B): S[t].discard(i) grundy^=A[i]^(A[i]-k) A[i]-=k for t in range(B): if bit(A[i],t): S[t].add(i) if phase()==-1: return turn^=1 #================================================== solve()