#include using namespace std; int main(){ int n, v = 0, p, x, s, M = 18; cin >> n; vector a(n); vector> S(M); for(int i = 0; i < n; i++){ cin >> a[i]; v ^= a[i]; for(int j = 0; j < M; j++){ if(a[i] >> j & 1)S[j].insert(i); } } auto update = [&](int p, int x){ v ^= a[p]; for(int j = 0; j < M; j++){ if(a[p] >> j & 1)S[j].erase(p); } a[p] -= x; v ^= a[p]; for(int j = 0; j < M; j++){ if(a[p] >> j & 1)S[j].insert(p); } }; auto my_turn = [&](){ int p = *S[__lg(v)].begin(); cout << p + 1 << " " << a[p] - (v ^ a[p]) << endl; update(p, a[p] - (v ^ a[p])); }; if(v == 0){ cout << 0 << endl; cin >> p >> x; update(--p, x); }else{ cout << 1 << endl; my_turn(); cin >> s; if(s == -1)return 0; cin >> p >> x; update(--p, x); cin >> s; if(s == -1)return 0; } while(true){ cin >> s; if(s == -1)return 0; my_turn(); cin >> s; if(s == -1)return 0; cin >> p >> x; update(--p, x); } }