#include <bits/stdc++.h>
using namespace std;
int x[1000], y[1000], cnt[4];
int a[1000][1000];
int px, py, id, xx, yy;
void tomove(int edx, int edy) {
  int recx, recy, flag;
  while (px != edx || py != edy) {
    if (px > edx)
      recx = px - 1;
    else if (px == edx)
      recx = px;
    else
      recx = px + 1;
    if (py > edy)
      recy = py - 1;
    else if (py == edy)
      recy = py;
    else
      recy = py + 1;
    if (px != recx && py != recy && a[recx][recy]) recx = px;
    printf("%d %d\n", recx, recy);
    fflush(stdout);
    scanf("%d %d %d", &id, &xx, &yy);
    if (id == -1 || id == 0) exit(0);
    a[x[id]][y[id]] = 0;
    a[xx][yy] = 1;
    x[id] = xx;
    y[id] = yy;
    px = recx;
    py = recy;
  }
}
int main() {
  scanf("%d %d", &px, &py);
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= 666; i++) {
    scanf("%d %d", &x[i], &y[i]);
    a[x[i]][y[i]] = 1;
  }
  tomove(500, 500);
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= 666; i++) {
    if (x[i] < 500 && y[i] < 500)
      cnt[0]++;
    else if (x[i] < 500)
      cnt[1]++;
    else if (y[i] < 500)
      cnt[2]++;
    else
      cnt[3]++;
  }
  if (cnt[0] <= 166) tomove(999, 999);
  if (cnt[1] <= 166) tomove(999, 1);
  if (cnt[2] <= 166) tomove(1, 999);
  if (cnt[3] <= 166) tomove(1, 1);
  return 0;
}
