from heapq import heappop,heappush from operator import itemgetter n=int(input()) A=list(map(int,input().split())) XOR=0 for a in A: XOR^=a if XOR==0: print(0,flush=True) i,k=map(int,input().split()) XOR^=A[i-1] A[i-1]-=k XOR^=A[i-1] ret=int(input()) if ret==-1: exit() else: print(1,flush=True) H=[] for i in range(n): H.append((-A[i],i)) H.sort(key=itemgetter(0)) while H: k,ind=heappop(H) if A[ind]!=-k: continue k=-k nec=XOR^k print(ind+1,k-nec,flush=True) ret=int(input()) if ret==-1: exit() A[ind]=nec XOR=0 if nec!=0: heappush(H,(-nec,ind)) i,k=map(int,input().split()) XOR^=A[i-1] A[i-1]-=k XOR^=A[i-1] if A[i-1]!=0: heappush(H,(-A[i-1],i-1)) ret=int(input()) if ret==-1: exit()