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.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

public class Codeforces {

    private static Print writer;

    private static Scan reader;

    static class Scan {
        private byte[] buf = new byte[1024]; // Buffer of Bytes
        private int index;
        private InputStream in;
        private int total;

        public Scan() throws IOException {
            in = System.in;
        }

        private int next() throws IOException { // Scan method used to scan buf
            if (total < 0)
                throw new InputMismatchException();
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0)
                    return -1;
            }
            return buf[index++];
        }

        int ni() throws IOException {
            int integer = 0;
            int n = next();
            while (isWhiteSpace(n)) // Removing startPointing whitespaces
                n = next();
            int neg = 1;
            if (n == '-') { // If Negative Sign encounters
                neg = -1;
                n = next();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = next();
                } else
                    throw new InputMismatchException();
            }
            return neg * integer;
        }

        long nl() throws IOException {
            long integer = 0;
            int n = next();
            while (isWhiteSpace(n)) // Removing startPointing whitespaces
                n = next();
            int neg = 1;
            if (n == '-') { // If Negative Sign encounters
                neg = -1;
                n = next();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = next();
                } else
                    throw new InputMismatchException();
            }
            return neg * integer;
        }

        String line() throws IOException {
            StringBuilder sb = new StringBuilder();
            int n = next();
            while (isWhiteSpace(n))
                n = next();
            while (!isNewLine(n)) {
                sb.append((char) n);
                n = next();
            }
            return sb.toString();
        }

        private boolean isNewLine(int n) {
            return n == '\n' || n == '\r' || n == -1;
        }

        private boolean isWhiteSpace(int n) {
            return n == ' ' || isNewLine(n) || n == '\t';
        }

        int[] nia(int n) throws Exception {
            if (n < 0)
                throw new Exception("Array size should be non negative");
            int[] array = new int[n];
            for (int i = 0; i < n; i++)
                array[i] = ni();
            return array;
        }

        int[][] n2dia(int r, int c) throws Exception {
            if (r < 0 || c < 0)
                throw new Exception("Array size should be non negative");
            int[][] array = new int[r][c];
            for (int i = 0; i < r; i++)
                array[i] = nia(c);
            return array;
        }

        long[] nla(int n) throws Exception {
            if (n < 0)
                throw new Exception("Array size should be non negative");
            long[] array = new long[n];
            for (int i = 0; i < n; i++)
                array[i] = nl();
            return array;
        }

        float[] nfa(int n) throws Exception {
            if (n < 0)
                throw new Exception("Array size should be non negative");
            float[] array = new float[n];
            for (int i = 0; i < n; i++)
                array[i] = nl();
            return array;
        }

        double[] nda(int n) throws Exception {
            if (n < 0)
                throw new Exception("Array size should be non negative");
            double[] array = new double[n];
            for (int i = 0; i < n; i++)
                array[i] = nl();
            return array;
        }
    }

    static class Print {
        private final BufferedWriter bw;

        Print() {
            bw = new BufferedWriter(new OutputStreamWriter(System.out));
        }

        <T> void print(T str) {
            try {
                bw.append(str.toString());
            } catch (IOException e) {
                System.out.println(e.toString());
            }
        }

        void println() {
            print("\n");
        }

        <T> void println(T str) {
            print(str + "\n");
        }

        void flush() throws IOException {
            bw.flush();
        }

        void close() {
            try {
                bw.close();
            } catch (IOException e) {
                System.out.println(e.toString());
            }
        }
    }

    public static void main(String[] args) throws Exception {
        long startPointTime = System.currentTimeMillis();
        reader = new Scan();
        writer = new Print();
        main2();
        long endTime = System.currentTimeMillis();
        float totalProgramTime = endTime - startPointTime;
        if (args.length > 0 && args[0].equals("time"))
            writer.print("Execution time is " + totalProgramTime + " (" + (totalProgramTime / 1000) + "s)");
        writer.close();
    }

    static class DisjointSet {
        int[] arr;
        int[] size;

        DisjointSet(int n) {
            arr = new int[n + 1];
            size = new int[n + 1];
            makeSet();
        }

        void makeSet() {
            for (int i = 1; i < arr.length; i++) {
                arr[i] = i;
                size[i] = 1;
            }
        }

        void union(int i, int j) {
            if (i == j)
                return;
            if (i > j) {
                i ^= j;
                j ^= i;
                i ^= j;
            }

            i = find(i);
            j = find(j);

            if (i == j)
                return;
            arr[j] = arr[i];
            size[i] += size[j];
            size[j] = size[i];
        }

        int find(int i) {
            if (arr[i] != i) {
                arr[i] = find(arr[i]);
                size[i] = size[arr[i]];
            }
            return arr[i];
        }

        int getSize(int i) {
            i = find(i);
            return size[i];
        }

        public String toString() {
            return Arrays.toString(arr);
        }
    }

    static long MOD = 1_000_000_007L;

    static class Point {
        int row;
        int col;

        Point(int row, int col) {
            this.row = row;
            this.col = col;
        }
    }

    static int[][] board;
    static Map<Integer, Point> map;
    static Point king;

    static void main2() throws Exception {
        int col = reader.ni();
        int row = reader.ni();
        king = new Point(row, col);

        board = new int[1000][1000];
        map = new HashMap<>();

        for (int i = 1; i <= 666; i++) {
            col = reader.ni();
            row = reader.ni();
            map.put(i, new Point(row, col));
            board[row][col] = i;
        }

        // take king to centre
        while (king.row != 500 || king.col != 500) {
            Point delta = getDirection(500, 500);
            if (board[king.row + delta.row][king.col + delta.col] != 0) {
                // rook found
                moveKing(king.row + delta.row, king.col);
                return;
            } else {
                if (moveKing(king.row + delta.row, king.col + delta.col)) {
                    return;
                }
            }
        }

        // king now at centre
        // find which corner to go to
        // this is a diff point
        Point[] data = getCorner();
        Point corner = data[0];
        Point diff = data[1];
        while (king.row != corner.row || king.col != corner.col) {
            if (board[king.row + diff.row][king.col + diff.col] != 0) {
                // if rook at diagonal..we can win
                moveKing(king.row + diff.row, king.col);
                return;
            } else {
                if (moveKing(king.row + diff.row, king.col + diff.col))
                    return;
            }
        }
    }

    static Point getDirection(int row, int col) {
        Point p = new Point(0, 0);
        if (king.row == row)
            p.row = 0;
        else if (king.row > row)
            p.row = -1;
        else
            p.row = 1;

        if (king.col == col)
            p.col = 0;
        else if (king.col > col)
            p.col = -1;
        else
            p.col = 1;
        return p;
    }

    static boolean moveKing(int newRow, int newCol) throws Exception {
        king.row = newRow;
        king.col = newCol;
        writer.println(king.col + " " + king.row);
        writer.flush();

        int r = reader.ni();
        int rncol = reader.ni();
        int rnrow = reader.ni();

        if (r == -1) {
            // game over
            return true;
        } else if (r == 0) {
            // fail
            return true;
        }
        board[map.get(r).row][map.get(r).col] = 0;
        map.get(r).row = rnrow;
        map.get(r).col = rncol;
        board[rnrow][rncol] = r;
        return false;
    }

    static Point[] getCorner() {
        int quadI = 0, quadII = 0, quadIII = 0, quadIV = 0;

        for (int row = 1; row < 1000; row++) {
            for (int col = 0; col < 1000; col++) {
                if (board[row][col] == 0)
                    continue;
                else {
                    if (row < 500 && col < 500) {
                        quadII++;
                    } else if (row < 500 && col > 500) {
                        quadI++;
                    } else if (row > 500 && col < 500) {
                        quadIII++;
                    } else {
                        quadIV++;
                    }
                }
            }
        }
        int min = min(quadI, quadII, quadIII, quadIV);
        if (quadI == min) {
            // go to quad III
            return new Point[] { new Point(999, 1), new Point(1, -1) };
        } else if (quadII == min) {
            return new Point[] { new Point(999, 999), new Point(1, 1) };
        } else if (quadIII == min) {
            return new Point[] { new Point(1, 999), new Point(-1, 1) };
        }
        return new Point[] { new Point(1, 1), new Point(-1, -1) };
    }

    static int min(int... arr) {
        int min = Integer.MAX_VALUE;
        for (int var : arr) {
            min = Math.min(min, var);
        }
        return min;
    }

    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
}