#include <bits/stdc++.h>
int x, y, k, c[4];
bool ocp[1000][1000];
struct POS {
  int x, y;
} p[667];
void to(int dx, int dy) {
  x += dx, y += dy;
  if (ocp[x][y]) x -= dx;
  printf("%d %d\n", x, y);
  fflush(stdout);
  scanf("%d", &k);
  if (k == -1) exit(0);
  if (k == 0) exit(0);
  ocp[p[k].x][p[k].y] = false;
  scanf("%d%d", &p[k].x, &p[k].y);
  ocp[p[k].x][p[k].y] = true;
}
int main() {
  scanf("%d%d", &x, &y);
  for (int i = 1; i <= 666; i++) {
    scanf("%d%d", &p[i].x, &p[i].y);
    ocp[p[i].x][p[i].y] = true;
  }
  while (x < 500) to(1, 0);
  while (x > 500) to(-1, 0);
  while (y < 500) to(0, 1);
  while (y > 500) to(0, -1);
  for (int i = 1; i <= 666; i++) {
    if (p[i].x < 500 && p[i].y < 500) c[0]++;
    if (p[i].x < 500 && p[i].y > 500) c[1]++;
    if (p[i].x > 500 && p[i].y < 500) c[2]++;
    if (p[i].x > 500 && p[i].y > 500) c[3]++;
  }
  int id = 0;
  for (int i = 1; i <= 3; i++)
    if (c[i] < c[id]) id = i;
  switch (id) {
    case 0: {
      while (x < 1000 && y < 1000) to(1, 1);
      break;
    }
    case 1: {
      while (x < 1000 && y > 0) to(1, -1);
      break;
    }
    case 2: {
      while (x > 0 && y < 1000) to(-1, 1);
      break;
    }
    case 3: {
      while (x > 0 && y > 0) to(-1, -1);
      break;
    }
  }
}
