#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;
ll mmod= 998244353;



int main(){
  int n;
  cin >>n;
  if(n%2==1){cout << 1 << " " << (n+1)/2 << endl;}
  else{cout << 2 << " " << n/2 <<endl;}

  while(1){
    int t;
    cin >>t;
    if(t==0 || t==1)return 0;
    if(t==2 || t==3){
      int k,x;
      cin >> k >>x;
      if(t==2)return 0;
      int d;
      if(x<(n+2)/2){d=x+(n+2)/2;}else{d=x-(n+2)/2;}
      if(n%2==1){cout << k << " " << d << endl;}
      else{cout << k << " " << d << endl;}
    }

  }
}