Problem: This is an interactive task.

Dasha and NN like playing chess. While playing a match they decided that normal chess isn't interesting enough for them, so they invented a game described below.

There are 666 black rooks and 1 white king on the chess board of size 999 × 999. The white king wins if he gets checked by rook, or, in other words, if he moves onto the square which shares either a row or column with a black rook.

The sides take turns, starting with white. NN plays as a white king and on each of his turns he moves a king to one of the squares that are adjacent to his current position either by side or diagonally, or, formally, if the king was on the square (x, y), it can move to the square (nx, ny) if and only max (|nx - x|, |ny - y|) = 1 , 1 ≤ nx, ny ≤ 999. NN is also forbidden from moving onto the squares occupied with black rooks, however, he can move onto the same row or column as a black rook.

Dasha, however, neglects playing by the chess rules, and instead of moving rooks normally she moves one of her rooks on any space devoid of other chess pieces. It is also possible that the rook would move onto the same square it was before and the position wouldn't change. However, she can't move the rook on the same row or column with the king.

Each player makes 2000 turns, if the white king wasn't checked by a black rook during those turns, black wins. 

NN doesn't like losing, but thinks the task is too difficult for him, so he asks you to write a program that will always win playing for the white king. Note that Dasha can see your king and play depending on its position.

Input

In the beginning your program will receive 667 lines from input. Each line contains two integers x and y (1 ≤ x, y ≤ 999) — the piece's coordinates. The first line contains the coordinates of the king and the next 666 contain the coordinates of the rooks. The first coordinate denotes the number of the row where the piece is located, the second denotes the column. It is guaranteed that initially the king isn't in check and that all pieces occupy different squares.

Output

After getting king checked, you program should terminate immediately without printing anything extra.

Interaction

To make a move with the king, output two integers x and y (1 ≤ x, y ≤ 999) — the square to which the king would be moved. The king cannot move onto the square already occupied by a rook. It is guaranteed that the king would always have a valid move.

After each of your turns read the rook's turn in the following format: a single line containing three integers k, x and y (1 ≤ k ≤ 666, 1 ≤ x_i, y_i ≤ 999) — the number of the rook that would move and the square it would move to. It is guaranteed that the rook wouldn't move to a square already occupied by another chess piece, but it can move onto the square where it was before the turn so that its position wouldn't change. It is guaranteed that the move does not put your king into a check. If your king got in check, all three integers would be equal to -1 and in that case your program should terminate immediately.

After printing your turn do not forget to output end of line and flush the output. Otherwise you will get Idleness limit exceeded. To do this, use:

  * fflush(stdout) or cout.flush() in C++;
  * System.out.flush() in Java;
  * flush(output) in Pascal;
  * stdout.flush() in Python;
  * see documentation for other languages.



Answer "0 0 0" instead of a correct answer means that you made an invalid query. Exit immediately after receiving "0 0 0" and you will see Wrong answer verdict. Otherwise you can get an arbitrary verdict because your solution will continue to read from a closed stream.

Hacks are not allowed for this problem.

Example

Input

999 999
1 1
1 2
2 1
2 2
1 3
2 3
&lt;...&gt;
26 13
26 14
26 15
26 16

1 700 800

2 1 2

&lt;...&gt;

-1 -1 -1


Output












999 998

999 997

&lt;...&gt;

999 26

Note

The example is trimmed. The full initial positions of the rooks in the first test are available at <https://pastebin.com/qQCTXgKP>. It is not guaranteed that they will behave as in the example.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
double tick() {
  static clock_t oldtick;
  clock_t newtick = clock();
  double diff = 1.0 * (newtick - oldtick) / CLOCKS_PER_SEC;
  oldtick = newtick;
  return diff;
}
long long gcd(long long a, long long b) {
  if ((a == 0) || (b == 0)) {
    return a + b;
  }
  return gcd(b, a % b);
}
long long powMod(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return (res % 1000000007);
}
long long pow2(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a);
    a = (a * a);
    b >>= 1;
  }
  return res;
}
bool isPrime(long long a) {
  for (long long i = 3; (i * i) <= a; i += 2) {
    if ((a % i) == 0) return false;
  }
  if ((a != 2) && ((a % 2) == 0)) {
    return false;
  }
  if (a == 1) {
    return false;
  }
  return true;
}
string conLlToStr(long long a) {
  stringstream mystr;
  mystr << a;
  return mystr.str();
}
long long conStrToLl(string st) {
  long long numb = 0;
  long long len = st.size(), i, j = 0;
  for (long long i = len - 1; i >= 0; i--) {
    numb += (pow2(10, j) * (st[i] - '0'));
    j++;
  }
  return numb;
}
long long basenoToDecimal(string st, long long basee) {
  long long i = 0, j, anss = 0;
  for (long long j = (int)st.length() - 1; j >= 0; j--) {
    anss += (st[j] - '0') * pow2(basee, i);
    i++;
  }
  return anss;
}
string decimalToString(long long num, long long basee) {
  long long i = 0, j, opop;
  string anss = "";
  vector<string> stri;
  stri.push_back("0");
  stri.push_back("1");
  stri.push_back("2");
  stri.push_back("3");
  stri.push_back("4");
  stri.push_back("5");
  stri.push_back("6");
  stri.push_back("7");
  stri.push_back("8");
  stri.push_back("9");
  stri.push_back("A");
  stri.push_back("B");
  stri.push_back("C");
  stri.push_back("D");
  stri.push_back("E");
  stri.push_back("F");
  if (num == 0) {
    return "0";
  }
  while (num) {
    opop = (num % basee);
    anss += stri[opop];
    num /= basee;
  }
  reverse(anss.begin(), anss.end());
  return anss;
}
long long my_sqrt(long long x) {
  long long y = (long long)(sqrtl((long double)x) + 0.5);
  while (y * y < x) {
    y++;
  }
  while (y * y > x) {
    y--;
  }
  if (y * y == x) {
    return y;
  }
  return -1;
}
long long my_crt(long long x) {
  long long y = (long long)(powl((long double)x, 1.0 / 3.0) + 0.5);
  while (y * y * y < x) {
    y++;
  }
  while (y * y * y > x) {
    y--;
  }
  if (y * y * y == x) {
    return y;
  }
  return -1;
}
const int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1};
long long rookx[1010], rooky[1010], row[1010], col[1010], K, X, Y;
set<pair<long long, long long> > rookspos;
bool flag;
void check(long long i, long long Y) {
  cout << i << " " << Y << "\n";
  fflush(stdout);
  if (row[i] || col[Y]) {
    flag = 1;
    return;
  }
  cin >> K >> X >> Y;
  fflush(stdout);
  rookspos.erase(make_pair(rookx[K], rooky[K]));
  rookspos.insert(make_pair(X, Y));
  row[rookx[K]]--;
  col[rooky[K]]--;
  row[X]++;
  col[Y]++;
  rookx[K] = X;
  rooky[K] = Y;
}
long long countofrooks(long long ind1, long long ind2, long long ind3,
                       long long ind4) {
  long long coun = 0;
  for (long long i = ind1; i <= ind3; i++) {
    for (long long j = ind2; j <= ind4; j++) {
      if (rookspos.find(make_pair(i, j)) != rookspos.end()) {
        coun++;
      }
    }
  }
  return coun;
}
pair<long long, long long> oppoofleast() {
  long long topl = countofrooks(1, 1, 500, 500);
  long long topr = countofrooks(1, 500, 500, 999);
  long long bell = countofrooks(500, 1, 999, 500);
  long long belr = countofrooks(500, 500, 999, 999);
  vector<pair<long long, pair<long long, long long> > > sorted;
  sorted.push_back(make_pair(topl, make_pair(1, 1)));
  sorted.push_back(make_pair(topr, make_pair(1, -1)));
  sorted.push_back(make_pair(bell, make_pair(-1, 1)));
  sorted.push_back(make_pair(belr, make_pair(-1, -1)));
  sort(sorted.begin(), sorted.end());
  return sorted[0].second;
}
bool isValid(pair<long long, long long> pos) {
  if (pos.first > 0 && pos.first < 1000 && pos.second > 0 &&
      pos.second < 1000) {
    return 1;
  }
  return 0;
}
int main() {
  cin >> X >> Y;
  for (long long i = 1; i <= 666; i++) {
    cin >> rookx[i] >> rooky[i];
    row[rookx[i]]++;
    col[rooky[i]]++;
    rookspos.insert(make_pair(rookx[i], rooky[i]));
  }
  if (X < 500) {
    for (long long i = X + 1; i <= 500; i++) {
      check(i, Y);
      if (flag) {
        return 0;
      }
    }
  } else {
    for (long long i = X - 1; i >= 500; i--) {
      check(i, Y);
      if (flag) {
        return 0;
      }
    }
  }
  if (Y < 500) {
    for (long long i = Y + 1; i <= 500; i++) {
      check(500, i);
      if (flag) {
        return 0;
      }
    }
  } else {
    for (long long i = Y - 1; i >= 500; i--) {
      check(500, i);
      if (flag) {
        return 0;
      }
    }
  }
  pair<long long, long long> whichmove = oppoofleast();
  pair<long long, long long> pos = make_pair(500, 500);
  for (long long i = 1; i <= 500; i++) {
    pair<long long, long long> temppos = pos;
    pos.first += whichmove.first;
    pos.second += whichmove.second;
    if (!isValid(pos) ||
        rookspos.find(make_pair(pos.first, pos.second)) != rookspos.end()) {
      pos = make_pair(temppos.first, temppos.second + whichmove.second);
    }
    if (!isValid(pos) ||
        rookspos.find(make_pair(pos.first, pos.second)) != rookspos.end()) {
      pos = make_pair(temppos.first + whichmove.first, temppos.second);
    }
    check(pos.first, pos.second);
    if (flag) {
      return 0;
    }
  }
  return 0;
}