#t540. 烦人的幻灯片
烦人的幻灯片
Matching Slides
Special for beginners, ^_^
Problem Description
Professor Li will give a very important lecture this afternoon. Unfortunately he is not a very tidy person and has piled up the slides he needs for the lecture in a random heap. So before the lecture he has to sort them out. As an efficiency-minded scholar, he wants to finish this as simply as possible. The professor needs slides for this lecture (); these slides are already numbered in the order they will be used in the lecture. Because the slides are transparent, we cannot see at once which number corresponds to which slide.
Now we number the slides again in order with capital letters . Your task is to write a program that matches the slides' number labels with their letter labels. This matching should obviously be unique; if multiple matchings are possible, or if some number label cannot be matched to any letter label, we say the matching is impossible.
Input Format
The first line has a single integer : there are slides.
The next lines each contain 4 integers (the integers are separated by spaces), the coordinates of a slide. These slides are numbered in the order they appear in the file, from front to back.
The next lines give the coordinates of the number labels in turn; obviously no number label lies outside a slide.
Output Format
If the matching is possible, the output should contain lines: each line a letter and a number separated by a space, ordered by increasing letter. Note that the letters must be uppercase and left-aligned. Otherwise, if the matching is impossible, print None at the left margin of the first line. There is no extra space at the end of the first line.
Sample Input 1
4
6 22 10 20
4 18 6 16
8 20 2 18
10 24 4 8
9 15
19 17
11 7
21 11
Sample Output 1
A 4
B 1
C 2
D 3
Constraints
1s, 1024KiB for each test case.