#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, a, b, N = 1000, dx, dy, a1, b1, k1 = 0, mx = 0, k2 = 0, k3 = 0,
                     k4 = 0, fx, fy;
  bool rook[N][N];
  memset(rook, false, sizeof(rook));
  cin >> a >> b;
  int x[N], y[N];
  for (i = 1; i <= 666; i++) {
    cin >> x[i] >> y[i];
    rook[x[i]][y[i]] = true;
  }
  while (1) {
    if (a == 500 && b == 500) break;
    dx = 0, dy = 0;
    if (500 - a > 0) dx = 1;
    if (a - 500 > 0) dx = -1;
    if (500 - b > 0) dy = 1;
    if (b - 500 > 0) dy = -1;
    a1 = a + dx, b1 = b + dy;
    if (rook[a1][b1]) {
      cout << a1 << " " << b << endl;
      cout.flush();
      cin >> k >> i >> j;
      return 0;
    }
    cout << a1 << " " << b1 << endl;
    cout.flush();
    cin >> k >> i >> j;
    if (k <= 0) return 0;
    rook[i][j] = true;
    rook[x[k]][y[k]] = false;
    x[k] = i, y[k] = j;
    a = a1, b = b1;
  }
  for (i = 1; i <= 666; i++) {
    if (x[i] <= 500 && y[i] <= 500) {
      k1++, k2++, k3++;
    }
    if (x[i] >= 500 && y[i] <= 500) {
      k1++;
      k2++;
      k4++;
    }
    if (y[i] >= 500 && x[i] <= 500) {
      k1++;
      k3++;
      k4++;
    }
    if (x[i] >= 500 && y[i] >= 500) {
      k2++;
      k3++;
      k4++;
    }
  }
  mx = max(k1, k2);
  mx = max(mx, k3);
  mx = max(mx, k4);
  if (k1 == mx) fx = 1, fy = 1;
  if (k2 == mx) fx = 999, fy = 1;
  if (k3 == mx) fx = 1, fy = 999;
  if (k4 == mx) fx = 999, fy = 999;
  dx = -1;
  if (fx > a) dx = 1;
  dy = -1;
  if (fy > b) dy = 1;
  while (1) {
    a1 = a + dx;
    b1 = b + dy;
    if (rook[a1][b1]) {
      cout << a1 << " " << b << endl;
      cout.flush();
      cin >> k >> i >> j;
      return 0;
    }
    cout << a1 << " " << b1 << endl;
    cout.flush();
    cin >> k >> i >> j;
    if (k <= 0) return 0;
    rook[i][j] = true;
    rook[x[k]][y[k]] = false;
    x[k] = i;
    y[k] = j;
    a = a1, b = b1;
  }
  return 0;
}
