#include using namespace std; int main(){ //ios::sync_with_stdio(false); //cin.tie(0); int n, v = 0, p, x, s; cin >> n; vector a(n); queue q; for(int i = 0; i < n; i++){ cin >> a[i]; q.push(i); v ^= a[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 = [&](){ while(!q.empty()){ int i = q.front(); q.pop(); if((a[i] ^ v) <= a[i]){ cout << i + 1 << " " << a[i] - (v ^ a[i]) << endl; update(i, a[i] - (v ^ a[i])); if(a[i] != 0)q.push(i); return; } if(a[i] != 0)q.push(i); } }; 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); } }