ICPC 2017 · Problem L · Visual Python++

41st ICPC · Rapid City, United States

Statement

Time limit: 5 seconds

In the recently proposed Visual Python++ programming language, a block of statements is represented as a rectangle of characters with top-left corner in row r1r_{1} and column c1c_{1}, and bottom-right corner in row r2r_{2} and column c2c_{2}. All characters at locations (r,c)(r, c) with r1rr2r1 \le r \le r2 and c1cc2c1 \le c \le c2 are then considered to belong to that block. Among these locations, the ones with r=r1r =r_{1} or r=r2r =r_{2} or c=c1c=c_{1} or c=c2c=c_{2} are called a border.

Statement blocks can be nested (rectangles contained in other rectangles) to an arbitrary level. In a syntac- tically correct program, every two statement blocks are either nested (one contained in the other) or disjoint (not overlapping). In both cases, their borders may not overlap.

Programmers are not expected to draw the many rectangles contained in a typical program – this takes too long, and Visual Python++ would not have a chance to become the next ICPC programming language. So a programmer only has to put one character ‘’ in the top-left corner of the rectangle and one character ‘’ in the bottom-right corner. The parser will automatically match up the appropriate corners to obtain the nesting structure of the program.

Your team has just been awarded a five-hour contract to develop this part of the parser.

Input

The first line of the input contains an integer nn (1n1051\le n\le 10^{5}), the number of corner pairs. Each of the next nn lines contains two integers rr and cc (1r,c1091\le r, c\le 10^{9}), specifying that there is a top-left corner in row rr and column cc of the program you are parsing. Following that are nn lines specifying the bottom-right corners in the same way. All corner locations are distinct.

Output

Display nn lines, each containing one integer. A number jj in line ii means that the iith top-left corner and the jjth bottom-right corner form one rectangle. Top-left and bottom-right corners are each numbered from 11 to nn in the order they appear in the input. The output must be a permutation of the numbers from 11 to nn such that the matching results in properly nested rectangles. If there is more than one valid matching, any one will be accepted. If no such matching exists, display syntax error.

Sample Input 1

2
4 7
9 8
14 17
19 18

Sample Output 1

2
1

ACM-ICPC World Finals 2017 Problem L: Visual Python++

Sample Input 2

2
4 7
14 17
9 8
19 18

Sample Output 2

1
2

Sample Input 3

2
4 8
9 7
14 18
19 17

Sample Output 3

syntax error

Sample Input 4

3
1 1
4 8
8 4
10 6
6 10
10 10

Sample Output 4

syntax error

ACM-ICPC World Finals 2017 Problem L: Visual Python++

No official solution in the source collection.