// Template #include #define rep_override(x, y, z, name, ...) name #define rep2(i, n) for (int i = 0; i < (n); ++i) #define rep3(i, l, r) for (int i = (l); i < (r); ++i) #define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__) #define per(i, n) for (int i = (n) - 1; i >= 0; --i) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; constexpr int inf = 1001001001; constexpr ll INF = 3003003003003003003; template inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;} template inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;} struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset; // Main int main() { int n; cin >> n; vector grundy(n + 1, 0); rep(i, 1, n + 1) { vector mex(i + 1, 0); rep(j, i) { if ((grundy[j] ^ grundy[i - j - 1]) <= i) mex[grundy[j] ^ grundy[i - j - 1]] = 1; } rep(j, i - 1) { if ((grundy[j] ^ grundy[i - j - 2]) <= i) mex[grundy[j] ^ grundy[i - j - 2]] = 1; } rep(j, i + 1) { if (mex[j] == 0) { grundy[i] = j; break; } } } vector board(n + 2, 0); board[0] = board[n + 1] = 1; while (true) { vector be, len; int cnt = 0; rep(i, 1, n + 2) { if (board[i] == 0) { ++cnt; } if (board[i] == 0 && board[i - 1] == 1) { be.push_back(i); } if (board[i] == 1 && board[i - 1] == 0) { len.push_back(cnt); cnt = 0; } } int g = 0; for (int l: len) g ^= grundy[l]; rep(i, be.size()) { rep(j, len[i]) { if ((g ^ grundy[len[i]] ^ grundy[j] ^ grundy[len[i] - j - 1]) == 0) { cout << 1 << " " << be[i] + j << endl; board[be[i] + j] = 1; goto joiho; } } rep(j, len[i] - 1) { if ((g ^ grundy[len[i]] ^ grundy[j] ^ grundy[len[i] - j - 2]) == 0) { cout << 2 << " " << be[i] + j << endl; board[be[i] + j] = 1; board[be[i] + j + 1] = 1; goto joiho; } } } joiho:; int t; cin >> t; if (t == 0 || t == 1) return 0; int k, x; cin >> k >> x; if (t == 2) return 0; board[x] = 1; if (k == 2) board[x + 1] = 1; } }