// Halle 1 #include #include #include #include #include #include ifstream in("slides.in"); #define DBG(x) struct slide { int x, y, xx ,yy; bool lbl[27]; bool OK; int cnt; int good; }; slide s[27]; // 1..26 int sss[27]; int ds = 0; int n; bool Read() { ++ds; int x, y; in >> n; if (n == 0) return false; for (int i = 1 ; i <=n; i++) { in >> s[i].x; in >> s[i].xx; in >> s[i].y; in >> s[i].yy; s[i].OK = false; s[i].cnt = 0; } for (int i = 1; i <= n; i++) { in >> x; in >> y; sss[i]=0; for (int j=1; j <=n; j++) { if ((s[j].x < x) && (s[j].xx > x) && (s[j].y < y) && (s[j].yy > y)) { //cout << "x"; s[j].lbl[i]=true; s[j].cnt++; sss[i]++; } else s[j].lbl[i]=false; } } // for (int i=1; i <= n; i++) cout << s[i].cnt << endl; return true; } void Run() { cout << "Heap " << ds << endl; int g; bool foundone; do { foundone = false; for (int i = 1; i <= n; i++) { //cout << ".\n"; if ((s[i].OK==false) && (s[i].cnt == 1)) { foundone=true; for (int j = 1; j <=n; j++) if (s[i].lbl[j]) g = j; //cout << "good " << i << " - " << g << endl; s[i].OK = true; s[i].good = g; for (int j = 1; j <= n; j++) { if (s[j].lbl[g]) { s[j].lbl[g]=false; s[j].cnt--; sss[g]--; } } } } if (!foundone) { for (int i=1;i<=n;i++) { if (sss[i]==1) { for (int j=1;j<=n;j++) { if (s[j].lbl[i]) { g=j; } } s[g].OK = true; s[g].good = i; s[g].lbl[i]=false; s[g].cnt--; sss[i]=0; } } } } while (foundone); char c = 0; for (int i = 1; i <= n; i++) if (s[i].OK) { c = 'A'+i-1; cout << "(" << c << "," << s[i].good << ") "; } if (c != 0) cout << endl; else cout << "none" << endl; cout << endl; } int main() { while (Read()) Run(); return 0; }