Niebieskie ksi.eczki
III Olympiad in Informatics 1995/1996

Task: WIE
Author: Krzysztof Diks
Rooks

II stage contest  

On the chessboard of size n*n (1<=n<=3000) we put n rooks. The arrangement of the rooks should satisfy the following rules:

For each i = 1,...,n, the i-th rook can be put on the rectangle specified by two pairs of coordinates: (ai, bi), (ci, di), where (ai, bi) are coordinates of the square in the left upper corner of the rectangle (row, column), (ci, di) are coordinates of the square in the right lower corner of the rectangle, 1 <= ai <= ci <= n and 1 <= bi <= di <= n. A field in the left upper square has coordinates (1, 1), a square in the right lower corner has coordinates (n, n).

No two rooks can attack each other, i.e. they cannot stay in the same row or the same column.

Task

Write a program which:

Input

In the first line of the input file WIE.IN there is written one positive integer n<=3000. In each of the following n lines there are written 4 positive integers not grater than n separated by single spaces. The numbers in the i-th line are the coordinates of the rectangle, in which  the i-th rook may be put (ai, bi, ci and di respectively).

Output

In the output file WIE.OUT there should be written one word NIE ("no" in Polish), or in each of n lines of the output file there should be written two integers separated by a single space. The numbers in the i-th line should denote the position of i-th rook (row, column). This position should be within the rectangle specified by coordinates in the (i+1)-th line of the input file WIE.IN. Pay attention to the fact that the positions of the rooks should be written in the same order as the coordinates of the rectangles were read from the file WIE.IN.

 

Example

For the file WIE.IN:
4
1 1 1 1
1 3 2 4
3 1 4 2
2 2 4 4

one of the correct solutions is the file WIE.OUT:
1 1
2 3
3 2
4 4

Your program should look for the file WIE.IN in the current directory and produce the output file WIE.OUT in the current directory too. The file containing the source code of your program should have a name WIE.???, whereas you should put three-letter abbreviation the of used programming language name instead of ???. The same program in executable form should be written in file WIE.EXE