#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; void solve() { int n; cin >> n; int xor_all = 0; vector a(n); set> s; for( int i = 0; i < n; i++ ) { cin >> a[i]; cout << a[i] << endl; xor_all ^= a[i]; s.insert(make_pair(a[i], i)); } auto julys_turn = [&]() -> void { int i, k; cin >> i >> k; i--; xor_all ^= a[i]^(a[i]-k); s.erase(make_pair(a[i], i)); s.insert(make_pair(a[i]-k, i)); a[i] -= k; }; auto my_turn = [&]() -> void { int i = (*s.rbegin()).second, k = a[i]-(xor_all^a[i]); s.erase(make_pair(a[i], i)); s.insert(make_pair(xor_all^a[i], i)); xor_all = 0; a[i] -= k; cout << i+1 << " " << k << endl; }; auto ret = [&]() -> int { int ret_; cin >> ret_; return ret_; }; if( xor_all == 0 ) { cout << 0 << endl; julys_turn(); if( ret() == -1 ) return; }else { cout << 1 << endl; } while(true) { my_turn(); if( ret() == -1 ) return; julys_turn(); if( ret() == -1 ) return; } } int main() { cin.tie(0); ios::sync_with_stdio(false); int t; t = 1; // cin >> t; while(t--) solve(); }