1 #define N 30
2 #include<vector>
3 #include<iostream>
4 using namespace std;
5 #include<cstdio>
6 #include<algorithm>
7 struct Edge{
8 int u;
9 vector<int>a;
10 bool operator <(const Edge&p)
11 const{return a.size()<p.a.size();}
12 }bh[N];
13 struct Kp{
14 int x1,x2,y1,y2;
15 }kp[N];
16 int flag[N],t=0,tot=0,n;
17 void input()
18 {
19 scanf("%d",&n);
20 for(int i=1;i<=n;++i)
21 {
22 scanf("%d%d%d%d",&kp[i].x1,&kp[i].x2,&kp[i].y1,&kp[i].y2);
23 }
24 // memset(flag,0,sizeof(flag));
25 }
26 void add_edge(int u,int v)
27 {
28 bh[u].u=u;
29 bh[u].a.push_back(v);
30 }
31 void add()
32 {
33 int xi,xa,yi,ya;
34 for(int i=1;i<=n;++i)
35 {
36 scanf("%d%d",&xi,&yi);
37 for(int j=1;j<=n;++j)
38 {
39 if(xi>=kp[j].x1&&xi<=kp[j].x2&&yi>=kp[j].y1&&yi<=kp[j].y2)
40 {
41 add_edge(i,j);
42 }
43 }
44 }
45 }
46 int main()
47 {
48 freopen("slides.in","r",stdin);
49 freopen("slides.out","w",stdout);
50 input();
51 add();
52 sort(bh+1,bh+n+1);
53 for(int i=1;i<=n;++i)
54 {
55 for(int j=0;j<bh[i].a.size();++j)
56 {
57 if(flag[bh[i].a[j]]==0)
58 {
59 int temp=bh[i].a[j];
60 flag[bh[i].a[j]]=bh[i].u;
61 tot++;
62 break;
63 }
64 }
65 }
66 int tbflag[N]={0};
67 for(int i=1;i<=n;++i)
68 {
69 for(int j=bh[i].a.size()-1;j>=0;--j)
70 {
71 if(tbflag[bh[i].a[j]]==0)
72 {
73 int temp=bh[i].a[j];
74 tbflag[bh[i].a[j]]=bh[i].u;
75 break;
76 }
77 }
78 }
79 bool fla=true;
80 for(int i=1;i<=n;++i)/*再反着做一次,是确保结果唯一的*/
81 {
82 if(tbflag[i]!=flag[i])
83 {
84 fla=false;break;
85 }
86 }
87 if(tot==n&&fla)
88 {
89 for(int i=1;i<=n;++i)
90 {
91 printf("%c %d\n",i+‘A‘-1,flag[i]);
92 }
93 }
94 else {
95 printf("None\n");
96 }
97 fclose(stdin);fclose(stdout);
98 return 0;
99 }