#include using namespace std; template struct BinaryTrie { struct Node { long long cnt = 0; int ch[2] = {-1, -1}; }; std::vector ns; BinaryTrie() : ns(1) {} long long size() const { return ns[0].cnt; } long long operator[](int k) const { return find_kth(k, 0); } long long find_kth(long long k, long long xor_add = 0) const { assert(0 <= k && k < size()); long long idx = 0, val = 0; for(int i=LOG-1; i>=0; i--) { long long c = xor_add >> i & 1; long long low_ch = ns[idx].ch[c]; long long low_cnt = (low_ch >= 0 ? ns[low_ch].cnt : 0); if (k < low_cnt) { idx = low_ch; } else { k -= low_cnt; idx = ns[idx].ch[c ^ 1]; val ^= 1LL << i; } assert(idx >= 0); } return val; } void add(long long val, long long cnt = 1) { assert(0 <= val && val < (1LL << LOG)); int idx = 0; for(int i=LOG-1; i>=0; i--) { ns[idx].cnt += cnt; assert(ns[idx].cnt >= 0); int &nxt = ns[idx].ch[val >> i & 1]; if (nxt == -1) { idx = nxt = ns.size(); ns.emplace_back(); } else { idx = nxt; } } ns[idx].cnt += cnt; assert(ns[idx].cnt >= 0); } long long lower_bound(long long val, long long xor_add = 0) { assert(0 <= val); if (val >= (1LL << LOG)) return size(); int idx = 0; long long cnt = 0; for(int i=LOG-1; i>=0; i--) { int b = val >> i & 1, c = xor_add >> i & 1; int ch = ns[idx].ch[c]; cnt += (b & (ch >= 0) ? ns[ch].cnt : 0); idx = ns[idx].ch[b ^ c]; if (idx < 0 or ns[idx].cnt == 0) break; } return cnt; } long long count(long long val) const { assert(0 <= val && val < (1LL << LOG)); int idx = 0; for(int i=LOG-1; i>=0; i--) { idx = ns[idx].ch[val >> i & 1]; if (idx < 0 or ns[idx].cnt == 0) return 0; } return ns[idx].cnt; } long long count(long long L, long long R, long long xor_add = 0) { assert(0 <= L && L <= R && R <= (1LL << LOG)); return lower_bound(R, xor_add) - lower_bound(L, xor_add); } long long xor_min(long long xor_add = 0) { return find_kth(0, xor_add); } long long xor_max(long long xor_add = 0) { return find_kth(size() - 1, xor_add); } }; int main(){ //ios::sync_with_stdio(false); //cin.tie(0); int n, v = 0, p, x, s; cin >> n; vector a(n); BinaryTrie<20> BT; set> S; for(int i = 0; i < n; i++){ cin >> a[i]; v ^= a[i]; BT.add(a[i], 1); S.insert({a[i], i}); } auto update = [&](int p, int x){ S.erase(make_pair(a[p], p)); BT.add(a[p], -1); v ^= a[p]; a[p] -= x; v ^= a[p]; if(a[p] >= 1){ S.insert(make_pair(a[p], p)); BT.add(a[p], 1); } }; auto my_turn = [&](){ for(int i = 0; i < n; i++){ if(a[i] == 0)continue; if((a[i] ^ v) < a[i]){ cout << i + 1 << " " << a[i] - (v ^ a[i]) << endl; update(i, a[i] - (v ^ a[i])); return; } } }; if(v == 0){ cout << 0 << endl; cin >> p >> x; update(--p, x); }else{ cout << 1 << endl; my_turn(); } while(true){ cin >> s; if(s == -1)break; my_turn(); cin >> s; if(s == -1)break; cin >> p >> x; update(--p, x); } }