#include #include #include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; namespace Segtree { using S = pair; S e(){ return {-1,-1}; } S op(S l, S r){ return max(l, r); } using RQ = atcoder::segtree; } int main(){ int N; cin >> N; vector A(N); rep(i,N) cin >> A[i]; Segtree::RQ rq(N); rep(i,N) rq.set(i, {A[i],i}); int allxor = 0; for(int a : A) allxor ^= a; auto readMove = [&](){ int i,k; cin >> i >> k; i--; allxor ^= A[i]; A[i] -= k; rq.set(i, {A[i],i}); allxor ^= A[i]; }; auto doMove = [&](){ int i = rq.all_prod().second; allxor ^= A[i]; int k = A[i] - allxor; cout << (i+1) << ' ' << k << endl; A[i] -= k; rq.set(i, {A[i],i}); allxor ^= A[i]; }; if(allxor != 0){ cout << 1 << endl; } else { cout << 0 << endl; readMove(); } while(true){ doMove(); int r; cin >> r; if(r <= 0) break; readMove(); } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;