#include <bits/stdc++.h>
using namespace std;
const long long MAX = 666;
pair<long long, long long> rook[MAX];
long long cnt[4];
long long x, y;
long long cuadrante(long long i) {
  if (x > rook[i].first) {
    if (y < rook[i].second) {
      return 0;
    } else {
      return 1;
    }
  }
  if (y > rook[i].second) {
    return 2;
  }
  return 3;
}
void doit() {
  cin >> x >> y;
  for (long long i = 0; i < (long long)MAX; i++) {
    cin >> rook[i].first >> rook[i].second;
  }
  while (x < 500) {
    x++;
    cout << x << " " << y << endl;
    long long k, a, b;
    cin >> k >> a >> b;
    if (k == -1 || a == -1 || b == -1) {
      return;
    }
    if (k == 0 || a == 0 || b == 0) {
      return;
    }
    k--;
    rook[k] = {a, b};
  }
  while (x > 500) {
    x--;
    cout << x << " " << y << endl;
    long long k, a, b;
    cin >> k >> a >> b;
    if (k == -1 || a == -1 || b == -1) {
      return;
    }
    if (k == 0 || a == 0 || b == 0) {
      return;
    }
    k--;
    rook[k] = {a, b};
  }
  while (y < 500) {
    y++;
    cout << x << " " << y << endl;
    long long k, a, b;
    cin >> k >> a >> b;
    if (k == -1 || a == -1 || b == -1) {
      return;
    }
    if (k == 0 || a == 0 || b == 0) {
      return;
    }
    k--;
    rook[k] = {a, b};
  }
  while (y > 500) {
    y--;
    cout << x << " " << y << endl;
    long long k, a, b;
    cin >> k >> a >> b;
    if (k == -1 || a == -1 || b == -1) {
      return;
    }
    if (k == 0 || a == 0 || b == 0) {
      return;
    }
    k--;
    rook[k] = {a, b};
  }
  for (long long i = 0; i < (long long)MAX; i++) {
    cnt[cuadrante(i)]++;
  }
  long long mini = 1e18;
  long long ind = -1;
  for (long long i = 0; i < (long long)4; i++) {
    if (cnt[i] < mini) {
      ind = i;
      mini = cnt[i];
    }
  }
  long long down, right;
  if (ind == 0) {
    down = 1;
    right = -1;
  }
  if (ind == 1) {
    down = 1;
    right = 1;
  }
  if (ind == 2) {
    down = -1;
    right = 1;
  }
  if (ind == 3) {
    down = -1;
    right = -1;
  }
  while (true) {
    x += down;
    y += right;
    for (long long i = 0; i < (long long)MAX; i++) {
      if (x == rook[i].first && y == rook[i].second) {
        x -= down;
        y -= right;
        if (x + down >= 1 && x + down <= 999) {
          x += down;
        } else {
          y += right;
        }
        break;
      }
    }
    if (x < 1) {
      x++;
    }
    if (y < 1) {
      y++;
    }
    if (x > 999) {
      x--;
    }
    if (y > 999) {
      y--;
    }
    cout << x << " " << y << endl;
    long long k, a, b;
    cin >> k >> a >> b;
    if (k == -1 && a == -1 && b == -1) {
      break;
    }
    if (k == 0 && a == 0 && b == 0) {
      break;
    }
    k--;
    rook[k] = {a, b};
  }
}
int main() {
  long long T = 1;
  while (T--) {
    doit();
  }
  return 0;
}
