#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 nn slides for this lecture (n≤26n\le26); these nn slides are already numbered 1∼n1\sim n 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 A,B,C…A,B,C\dots. 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 nn: there are nn slides.

The next nn lines each contain 4 integers xmin,xmax,ymin,ymaxxmin,xmax,ymin,ymax (the integers are separated by spaces), the coordinates of a slide. These nn slides are numbered A,B,C…A,B,C\dots in the order they appear in the file, from front to back.

The next nn lines give the coordinates x,yx,y of the nn number labels in turn; obviously no number label lies outside a slide.

Output Format

If the matching is possible, the output should contain nn 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.