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.*;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {
    static Main mm;
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        mm = new Main();
        mm.problemD(new Input(new BufferedReader(new InputStreamReader(System.in))), out);
        out.close();
    }

    static void problemD(Input in, PrintWriter out) throws IOException {
        int[] x=new int[667],y=new int[667];
        boolean center=false;
        boolean[][] b=new boolean[1000][1000];
        x[0]=in.nextInt();
        y[0]=in.nextInt();
        for (int i = 1; i < 667; i++) {
            x[i]=in.nextInt();
            y[i]=in.nextInt();
            b[x[i]][y[i]]=true;
        }
        int dx=500-x[0],dy=500-y[0];
        dx=dx!=0?dx>0?1:-1:0;
        dy=dy!=0?dy>0?1:-1:0;
        while(true) {
            if(x[0]==500&&y[0]==500) {
                center=true;
                int[] k={0,0,0,0};
                int[] ddx={+1,+1,-1,-1};
                int[] ddy={+1,-1,+1,-1};
                for (int i = 1; i < 1000; i++) {
                    for (int j = 1; j < 1000; j++) {
                        if(b[i][j])k[i/500*2+j/500]++;
                    }
                }
                int i=0;
                for (int j=1; j < 4; j++) {
                    if(k[j]<k[i])i=j;
                }
                dx=ddx[i];
                dy=ddy[i];
            }
            if(!center){
                if(x[0]==500)dx=0;
                if(y[0]==500)dy=0;
            }
            if(!b[x[0]+dx][y[0]+dy])
                x[0]+=dx;
            y[0]+=dy;
            out.print(x[0]);out.print(' ');out.println(y[0]);out.flush();
            int k=in.nextInt(),xx=in.nextInt(),yy=in.nextInt();
            if(k==-1 || k==0){
                return;
            }
            b[x[k]][y[k]]=false;
            x[k]=xx;y[k]=yy;
            b[x[k]][y[k]]=true;
        }
    }

    static void problemC(Input in, PrintWriter out) throws IOException {
        double n=in.nextDouble(),r=in.nextDouble();
        double a=2*Math.PI/n;
        double ca=Math.cos(a),sa=Math.sin(a);
        double left=0,right=1000;
        double R,eps=1e-8;
        while(true){
            R=(left+right)/2.0;
            double x0=R+r;
            double x=x0*ca,y=x0*sa;
            double d=Math.sqrt((x0-x)*(x0-x)+y*y);
            if(Math.abs(2*R-d)<eps) break;
            if(d>2*R)
                left=R;
            else
                right=R;
        }
        out.println(R);
    }

    static void problemB(Input in, PrintWriter out) throws IOException {
        int n=in.nextInt(),m=in.nextInt();
        int[] a=new int [n+1],b=new int[m+1];
        for (int i = 0; i < m; i++) {
            int t=in.nextInt();
            a[t]++;
            b[a[t]]++;
            out.print((b[a[t]]==n)?'1':'0');
        }
        out.println();
    }

    static void problemA(Input in, PrintWriter out) throws IOException {
        int n=in.nextInt(),k=in.nextInt(),s=0;
        int[] a=new int[k];
        for (int i = 0; i < n; i++) {
            int t=in.nextInt();
            a[i%k]+=t;
            s+=t;
        }
        int res=0;
        for (int i = 0; i < k; i++) {
            res=Math.max(res,Math.abs(s-a[i]));
        }
        out.println(res);
    }

    static class Input {
        BufferedReader in;
        StringBuilder sb = new StringBuilder();

        public Input(BufferedReader in) {
            this.in = in;
        }

        public Input(String s) {
            this.in = new BufferedReader(new StringReader(s));
        }

        public String next() throws IOException {
            sb.setLength(0);
            while (true) {
                int c = in.read();
                if (c == -1) {
                    return null;
                }
                if (" \n\r\t".indexOf(c) == -1) {
                    sb.append((char) c);
                    break;
                }
            }
            while (true) {
                int c = in.read();
                if (c == -1 || " \n\r\t".indexOf(c) != -1) {
                    break;
                }
                sb.append((char) c);
            }
            return sb.toString();
        }

        public char nextChar() throws IOException {
            while (true) {
                int c = in.read();
                if (c == -1) {
                    return (char) c;
                }
                if (" \n\r\t".indexOf(c) == -1) {
                    return (char) c;
                }
            }
        }

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

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }
}