from heapq import * n = int(input()) aa = list(map(int, input().split())) hp = [] x = 0 for i, a in enumerate(aa): x ^= a heappush(hp, (-a, i)) t = 1 if x else 0 print(t, flush=True) ret = 0 while ret == 0: if t: i = a = -1 while aa[i] != a: a, i = heappop(hp) a = -a b = x ^ a k = a-b print(i+1, k, flush=True) else: i, k = map(int, input().split()) i -= 1 a = aa[i] b = a-k x ^= a ^ b aa[i] = b if b: heappush(hp, (-b, i)) ret = int(input()) t ^= 1