#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
signed main() {
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << 2 << ' ' << n/2 << endl;
        while (1) {
            int tp;
            cin >> tp;
            if (tp == 0)
                exit(0);
            assert(tp == 3);

            int t, p;
            cin >> t >> p;
            int sh = n/2+1;
            if (p <= n/2) {
                cout << t << ' ' << p + sh << endl;
            }   
            else {
                cout << t << ' ' << p - sh << endl;
            }   
        }   
    }   
    else {
        cout << 1 << ' ' << n/2 + 1 << endl;
        while (1) {
            int tp;
            cin >> tp;
            if (tp == 0)
                exit(0);
            assert(tp == 3);

            int t, p;
            cin >> t >> p;
            int sh = n/2+1;
            if (p <= n/2) {
                cout << t << ' ' << p + sh << endl;
            }   
            else {
                cout << t << ' ' << p - sh << endl;
            }   
        }   
    }   
}