#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return {i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
using ld = long double;
using ll = long long;
constexpr int mod = 1000 * 1000 * 1000 + 7;
constexpr int odw2 = (mod + 1) / 2;
void OdejmijOd(int& a, int b) {
  a -= b;
  if (a < 0) a += mod;
}
int Odejmij(int a, int b) {
  OdejmijOd(a, b);
  return a;
}
void DodajDo(int& a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int Dodaj(int a, int b) {
  DodajDo(a, b);
  return a;
}
int Mnoz(int a, int b) { return (ll)a * b % mod; }
void MnozDo(int& a, int b) { a = Mnoz(a, b); }
int Pot(int a, int b) {
  int res = 1;
  while (b) {
    if (b % 2 == 1) MnozDo(res, a);
    a = Mnoz(a, a);
    b /= 2;
  }
  return res;
}
int Odw(int a) { return Pot(a, mod - 2); }
void PodzielDo(int& a, int b) { MnozDo(a, Odw(b)); }
int Podziel(int a, int b) { return Mnoz(a, Odw(b)); }
int Moduluj(ll x) {
  x %= mod;
  if (x < 0) x += mod;
  return x;
}
template <typename T>
T Maxi(T& a, T b) {
  return a = max(a, b);
}
template <typename T>
T Mini(T& a, T b) {
  return a = min(a, b);
}
struct Krotka {
  int id;
  ll x, y;
  int r12, r13, r23;
};
ll a, b;
int cnt = 0;
vector<Krotka> krotki;
int Query(ll x, ll y) {
  cnt++;
  printf("%lld %lld\n", x, y);
  fflush(stdout);
  int res;
  scanf("%d", &res);
  if (res == 0) {
    debug() << " ["
               "a"
               ": "
            << (a)
            << "] "
               " ["
               "b"
               ": "
            << (b)
            << "] "
               " ["
               "x"
               ": "
            << (x)
            << "] "
               " ["
               "y"
               ": "
            << (y)
            << "] "
               " ["
               "cnt"
               ": "
            << (cnt) << "] ";
    exit(0);
  }
  debug() << " ["
             "x"
             ": "
          << (x)
          << "] "
             " ["
             "y"
             ": "
          << (y)
          << "] "
             " ["
             "res"
             ": "
          << (res) << "] ";
  assert(1 <= res and res <= 3);
  return res;
}
void Prost(ll x1, ll x2, ll y1, ll y2);
void L(ll x1, ll x2, ll y1, ll y2, ll x3, ll y3) {
  debug() << "L("
             " ["
             "x1"
             ": "
          << (x1)
          << "] "
             " ["
             "x2"
             ": "
          << (x2)
          << "] "
             " ["
             "y1"
             ": "
          << (y1)
          << "] "
             " ["
             "y2"
             ": "
          << (y2)
          << "] "
             " ["
             "x3"
             ": "
          << (x3)
          << "] "
             " ["
             "y3"
             ": "
          << (y3)
          << "] "
             ")";
  assert(x1 <= x3 and x3 < x2);
  assert(y1 <= y3 and y3 < y2);
  ll x = (x1 + x3) / 2;
  ll y = (y1 + y3) / 2;
  switch (rand() % 3) {
    case 0: {
      x = x3;
      y = (y1 + y3) / 2;
      break;
    }
    case 1: {
      x = (x1 + x3) / 2;
      y = y3;
      break;
    }
    case 2: {
      break;
    }
    default: {
      assert(false);
    }
  }
  const int r = Query(x, y);
  if (r == 1) {
    if (x < x3) {
      return L(x + 1, x2, y1, y2, x3, y3);
    } else {
      return Prost(x + 1, x2, y1, y3);
    }
  } else if (r == 2) {
    if (y < y3) {
      return L(x1, x2, y + 1, y2, x3, y3);
    } else {
      return Prost(x1, x3, y + 1, y2);
    }
  } else if (r == 3) {
    if (x == x1) {
      return Prost(x1, x2, y1, y - 1);
    } else if (y == y1) {
      return Prost(x1, x - 1, y1, y2);
    } else {
      return L(x1, x2, y1, y2, x - 1, y - 1);
    }
  } else {
    assert(false);
  }
}
void Prost(ll x1, ll x2, ll y1, ll y2) {
  debug() << "Prost("
             " ["
             "x1"
             ": "
          << (x1)
          << "] "
             " ["
             "x2"
             ": "
          << (x2)
          << "] "
             " ["
             "y1"
             ": "
          << (y1)
          << "] "
             " ["
             "y2"
             ": "
          << (y2)
          << "] "
             ")";
  assert(x1 <= x2 and y1 <= y2);
  const ll x = (x1 + x2) / 2;
  const ll y = (y1 + y2) / 2;
  const int r = Query(x, y);
  if (r == 1) {
    return Prost(x + 1, x2, y1, y2);
  } else if (r == 2) {
    return Prost(x1, x2, y + 1, y2);
  } else if (r == 3) {
    if (x == x1) {
      return Prost(x1, x2, y1, y - 1);
    } else if (y == y1) {
      return Prost(x1, x - 1, y1, y2);
    } else {
      return L(x1, x2, y1, y2, x - 1, y - 1);
    }
  } else {
    assert(false);
  }
}
int main(int argc, char** argv) {
  ll n;
  scanf("%lld", &n);
  Prost(1, n, 1, n);
  assert(false);
}
