#include using namespace std; #define int long long #define ld long double #define debug(x) cout << "(" << #x << " : " << (x) << ")" << endl #define debughere cout << "HERE" << endl void solve() { int n; cin >> n; int xor_product = 0; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; xor_product ^= a[i]; } bool turn = (xor_product == 0 ? 0 : 1); cout << turn << endl; while (true) { if (turn == 1) { // giliran kita // untuk mencari suatu nilai yang bisa kita // buang supaya xornya 0, // kita bisa cari angka yang mengandung MSB dari // xor_product sekarang (MSB: most signficant bit) int msb = 1 << __lg(xor_product); // __lg() -> floor(log2()) for (int i = 0; i < n; i++) { if (a[i] & msb) { cout << i + 1 << ' ' << a[i] - (a[i] ^ xor_product) << endl; a[i] ^= xor_product; xor_product = 0; break; } } // xor becomes 0 } else { // giliran judge int i, k; cin >> i >> k; i--; xor_product = a[i] ^ (a[i] - k); a[i] -= k; // xor becomes non-0 } int ret; cin >> ret; // ini cuma pernah input iterasi pertama if (ret == -1) return; turn ^= 1; } // tujuan kita menang, maka kalo xor == 0, pilih player 2 // selain itu, pilih player 1 } signed main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); int t = 1; // cin >> t; while (t--) solve(); return 0; }