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 JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDashaAndChess solver = new DDashaAndChess();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDashaAndChess {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int[][] grid = new int[1000][1000];
            int[][] rooks = new int[667][2];
            int xk, yk;
            int x, y, r;
            xk = sc.nextInt();
            yk = sc.nextInt();
            grid[xk][yk] = 2;
            for (int i = 1; i <= 666; i++) {
                x = sc.nextInt();
                y = sc.nextInt();
                rooks[i][0] = x;
                rooks[i][1] = y;
                grid[x][y] = 1;
            }

            boolean centre = xk == 500 && yk == 500;
            while (!centre) {
                if (xk > 500 && yk > 500) {
                    if (grid[xk - 1][yk - 1] == 1) {
                        out.println((xk) + " " + (yk - 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk - 1] = 2;
                        yk = yk - 1;
                    } else {
                        out.println((xk - 1) + " " + (yk - 1));
                        grid[xk][yk] = 0;
                        grid[xk - 1][yk - 1] = 2;
                        xk--;
                        yk--;
                    }
                    out.flush();
                } else if (xk < 500 && yk < 500) {
                    if (grid[xk + 1][yk + 1] == 1) {
                        out.println((xk) + " " + (yk + 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk + 1] = 2;
                        yk++;
                    } else {
                        out.println((xk + 1) + " " + (yk + 1));
                        grid[xk][yk] = 0;
                        grid[xk + 1][yk + 1] = 2;
                        yk++;
                        xk++;
                    }
                    out.flush();
                } else if (xk > 500 && yk < 500) {
                    if (grid[xk - 1][yk + 1] == 1) {
                        out.println((xk) + " " + (yk + 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk + 1] = 2;
                        yk++;
                    } else {
                        out.println((xk - 1) + " " + (yk + 1));
                        grid[xk][yk] = 0;
                        grid[xk - 1][yk + 1] = 2;
                        yk++;
                        xk--;
                    }
                    out.flush();
                } else if (xk < 500 && yk > 500) {
                    if (grid[xk + 1][yk - 1] == 1) {
                        out.println((xk) + " " + (yk - 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk - 1] = 2;
                        xk--;
                    } else {
                        out.println((xk + 1) + " " + (yk - 1));
                        grid[xk][yk] = 0;
                        grid[xk + 1][yk - 1] = 2;
                        xk++;
                        yk--;
                    }
                    out.flush();
                } else if (xk == 500) {
                    if (yk > 500) {
                        out.println((xk) + " " + (yk - 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk - 1] = 2;
                        yk--;
                    } else {
                        out.println((xk) + " " + (yk + 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk + 1] = 2;
                        yk++;
                    }
                    out.flush();
                } else {
                    if (xk > 500) {
                        out.println((xk - 1) + " " + (yk));
                        grid[xk][yk] = 0;
                        grid[xk - 1][yk] = 2;
                        xk--;
                    } else {
                        out.println((xk + 1) + " " + (yk));
                        grid[xk][yk] = 0;
                        grid[xk + 1][yk] = 2;
                        xk++;
                    }
                    out.flush();
                }

                if (xk == 500 && yk == 500) {
                    centre = true;
                }
                r = sc.nextInt();
                x = sc.nextInt();
                y = sc.nextInt();
                if (r == -1 && x == -1 && y == -1) {
                    return;
                } else {
                    grid[rooks[r][0]][rooks[r][1]] = 0;
                    grid[x][y] = 1;
                    rooks[r][0] = x;
                    rooks[r][1] = y;
                }
            }
            int quad1 = 0;
            for (int i = 1; i < 500; i++) {
                for (int j = 1; j < 500; j++) {
                    if (grid[i][j] == 1)
                        quad1++;
                }
            }
            int quad2 = 0;
            for (int i = 501; i <= 999; i++) {
                for (int j = 501; j <= 999; j++) {
                    if (grid[i][j] == 1)
                        quad2++;
                }
            }
            int quad3 = 0;
            for (int i = 1; i < 500; i++) {
                for (int j = 501; j <= 999; j++) {
                    if (grid[i][j] == 1)
                        quad3++;
                }
            }

            int quad4 = 0;
            for (int i = 501; i <= 999; i++) {
                for (int j = 1; j < 500; j++) {
                    if (grid[i][j] == 1)
                        quad4++;
                }
            }
            if (Math.min(Math.min(quad1, quad2), Math.min(quad3, quad4)) == quad2) {
                while (xk > 0 && xk < 999 && yk > 0 && yk < 999) {
                    if (grid[xk - 1][yk - 1] == 1) {
                        out.println((xk) + " " + (yk - 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk - 1] = 2;
                        yk--;
                    } else {
                        out.println((xk - 1) + " " + (yk - 1));
                        grid[xk][yk] = 0;
                        grid[xk - 1][yk - 1] = 2;
                        xk--;
                        yk--;
                    }
                    out.flush();
                    r = sc.nextInt();
                    x = sc.nextInt();
                    y = sc.nextInt();
                    if (r == -1 && x == -1 && y == -1) {
                        return;
                    } else {
                        grid[rooks[r][0]][rooks[r][1]] = 0;
                        grid[x][y] = 1;
                        rooks[r][0] = x;
                        rooks[r][1] = y;
                    }
                }
            } else if (Math.min(Math.min(quad1, quad2), Math.min(quad3, quad4)) == quad1) {
                while (xk > 0 && xk < 999 && yk > 0 && yk < 999) {
                    if (grid[xk + 1][yk + 1] == 1) {
                        out.println((xk) + " " + (yk + 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk + 1] = 2;
                        yk++;
                    } else {
                        out.println((xk + 1) + " " + (yk + 1));
                        grid[xk][yk] = 0;
                        grid[xk + 1][yk + 1] = 2;
                        xk++;
                        yk++;
                    }
                    out.flush();
                    r = sc.nextInt();
                    x = sc.nextInt();
                    y = sc.nextInt();
                    if (r == -1 && x == -1 && y == -1) {
                        return;
                    } else {
                        grid[rooks[r][0]][rooks[r][1]] = 0;
                        grid[x][y] = 1;
                        rooks[r][0] = x;
                        rooks[r][1] = y;
                    }
                }
            } else if (Math.min(Math.min(quad1, quad2), Math.min(quad3, quad4)) == quad4) {
                while (xk > 0 && xk < 999 && yk > 0 && yk < 999) {
                    if (grid[xk - 1][yk + 1] == 1) {
                        out.println((xk) + " " + (yk + 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk + 1] = 2;
                        yk++;
                    } else {
                        out.println((xk - 1) + " " + (yk + 1));
                        grid[xk][yk] = 0;
                        grid[xk - 1][yk + 1] = 2;
                        xk--;
                        yk++;
                    }
                    out.flush();
                    r = sc.nextInt();
                    x = sc.nextInt();
                    y = sc.nextInt();
                    if (r == -1 && x == -1 && y == -1) {
                        return;
                    } else {
                        grid[rooks[r][0]][rooks[r][1]] = 0;
                        grid[x][y] = 1;
                        rooks[r][0] = x;
                        rooks[r][1] = y;
                    }
                }

            } else {
                while (xk > 0 && xk < 999 && yk > 0 && yk < 999) {
                    if (grid[xk + 1][yk - 1] == 1) {
                        out.println((xk) + " " + (yk - 1));
                        grid[xk][yk] = 0;
                        grid[xk][yk - 1] = 2;
                        yk--;
                    } else {
                        out.println((xk + 1) + " " + (yk - 1));
                        grid[xk][yk] = 0;
                        grid[xk + 1][yk - 1] = 2;
                        xk++;
                        yk--;
                    }
                    out.flush();
                    r = sc.nextInt();
                    x = sc.nextInt();
                    y = sc.nextInt();
                    if (r == -1 && x == -1 && y == -1) {
                        return;
                    } else {
                        grid[rooks[r][0]][rooks[r][1]] = 0;
                        grid[x][y] = 1;
                        rooks[r][0] = x;
                        rooks[r][1] = y;
                    }
                }
            }

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}