#include <bits/stdc++.h>
using namespace std;
vector<int>a[500005];
int dfn[500005],low[500005],tot,cnt,id[500005];
bool ins[500005];
stack<int>s;
void tarjan(int n1)
{
dfn[n1]=low[n1]=++tot;
s.push(n1);
ins[n1]=true;
for(int i=0;i<a[n1].size();i++)
{
if(!dfn[a[n1][i]])
{
tarjan(a[n1][i]);
low[n1]=min(low[n1],low[a[n1][i]]);
}
else if(ins[a[n1][i]]==true)
{
low[n1]=min(low[n1],dfn[a[n1][i]]);
}
}
if(dfn[n1]==low[n1])
{
cnt++;
while(s.top()!=n1)
{
id[s.top()]=cnt;
ins[s.top()]=false;
s.pop();
}
id[n1]=cnt;
ins[n1]=false;
s.pop();
}
}
int m[1005];
bool v[1005];
bool dfs(int n1)
{
v[n1]=true;
for(int i=0;i<a[n1].size();i++)
{
if(!m[a[n1][i]]||v[m[a[n1][i]]]==false&&dfs(m[a[n1][i]]))
{
m[a[n1][i]]=n1;
return true;
}
}
return false;
}
struct t1
{
int x1,x2,y1,y2;
}t[30];
int x[30],y[30];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T=0;
int n;
cin>>n;
while(n)
{
T++;
tot=cnt=0;
for(int i=1;i<=n;i++)
{
a[i].clear();
}
for(int i=1;i<=n;i++)
{
cin>>t[i].x1>>t[i].x2>>t[i].y1>>t[i].y2;
}
for(int i=1;i<=n;i++)
{
cin>>x[i]>>y[i];
m[i+n]=0;
for(int j=1;j<=n;j++)
{
if(x[i]>t[j].x1&&x[i]<t[j].x2&&y[i]>t[j].y1&&y[i]<t[j].y2)
{
a[j].push_back(i+n);
}
}
}
for(int i=1;i<=n;i++)
{
memset(v,false,sizeof(v));
dfs(i);
}
for(int i=1;i<=n;i++)
{
dfn[i]=dfn[i+n]=0;
a[i].clear();a[i+n].clear();
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(x[i]>t[j].x1&&x[i]<t[j].x2&&y[i]>t[j].y1&&y[i]<t[j].y2)
{
if(m[i+n]==j)
{
a[i+n].push_back(j);
}
else
{
a[j].push_back(i+n);
}
}
}
}
for(int i=1;i<=2*n;i++)
{
if(!dfn[i])
{
tarjan(i);
}
}
cout<<"Heap "<<T<<endl;
bool f=false;
for(int j=1;j<=n;j++)
{
for(int i=1;i<=n;i++)
{
if(x[i]>t[j].x1&&x[i]<t[j].x2&&y[i]>t[j].y1&&y[i]<t[j].y2)
{
if(m[i+n]==j&&id[i+n]!=id[j])
{
if(f==true)
{
cout<<" ";
}
f=true;
cout<<"("<<(char)(j+'A'-1)<<","<<i<<")";
}
}
}
}
if(f==false)
{
cout<<"none";
}
cout<<endl;
cout<<endl;
cin>>n;
}
return 0;
}