Uncle Jeff owns a glass shop, which sells glass panes for windows and picture frames. As you probably know, a glass pane can only be cut if the cut goes from edge to edge of the pane in a straight line. The figure below shows how a glass pane can be cut into three smaller glass panes.
The input contains several test cases. The first line of a test case contains an integer N indicating the number of windows and picture frames in the test (2 <= N <= 2000). Each of the next N lines contains four integers X1, Y1,X2, Y2, where (X1, Y1) and (X2,Y2) represent the lower-left and upper-right coordinates marked by uncle Jeff on the big glass pane (-5000 <= X1, Y1,X2, Y2 <= 5000; X1 < X2 and Y1 < Y2). You should assume the following of each test case:
For each test case in the input your program must produce an ordered list of cuts that must be performed to separate the big glass pane into the desired smaller panes. Each cut must appear in a different line. A cut is described by four integers X1, Y1, X2, Y2, where (X1, Y1) and (X2, Y2) specify the endpoints of the cut, with X1 < X2 and Y1 = Y2 for a horizontal cut and X1 = X2 and Y1 < Y2 for a vertical cut. As more than one ordering of cuts may be possible, your program must print the list in a particular order. If at some point more than one cut is possible, print first the cut with smaller X1; if more than one cut is still possible, print first the one with smaller Y1. Print a blank line after each test case list.
3 0 0 20 30 20 0 40 20 20 20 40 30 6 1 2 2 4 2 3 3 5 1 4 2 5 2 2 3 3 3 2 4 3 3 3 4 5 0
20 0 20 30 20 20 40 20 2 2 2 5 1 4 2 4 2 3 4 3 3 2 3 3 3 3 3 5