#include <bits/stdc++.h>

using namespace std;


typedef long long ll;

const int INF = 1e9 + 5;
const ll oo = 1e18 + 5;

const int MAXN = 105;

#define y1 asdsdfg
#define int ll

struct pii {
    int x1, x2, y1, y2;
};

int n, matchX[MAXN], matchY[MAXN], dist[MAXN], tests, old_matchX[MAXN];
pii a[MAXN];
pair<int, int> b[MAXN];
queue<int> q;
vector<int> adj[MAXN], g[MAXN];
bool findPath() {
    for (int i = 1; i <= n; ++i) {
        if (matchX[i] == 0) {
            q.push(i);
            dist[i] = 0;
        } else dist[i] = -1;
    }

    bool ok = false;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int i = 0; i < int(adj[u].size()); ++i) {
            int v = adj[u][i];
            if (matchY[v] == 0) {
                ok = true;
            } else {
                if (dist[matchY[v]] < 0) {
                    dist[matchY[v]] = dist[u] + 1;
                    q.push(matchY[v]);
                }
            }
        }
    }
    return ok;
}
bool match(int u) {
    for (int i = 0; i < int(adj[u].size()); ++i) {
        int v = adj[u][i];
        if (matchY[v] == 0) {
            matchX[u] = v;
            matchY[v] = u;
            return true;
        } else {
            if ((dist[matchY[v]] == dist[u] + 1) && match(matchY[v])) {
                matchX[u] = v;
                matchY[v] = u;
                return true;
            }
        }
    }
    return false;
}


void solve() {
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].x1 >> a[i].x2 >> a[i].y1 >> a[i].y2;
    }


    for (int i = 1; i <= n; ++i) {
        cin >> b[i].first >> b[i].second;
    }


    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (a[i].x1 < b[j].first && b[j].first < a[i].x2 && a[i].y1 < b[j].second && b[j].second < a[i].y2) {
                adj[i].push_back(j);
                g[i].push_back(j);
            }
        }
    }

    while (findPath()) {
        for (int i = 1; i <= n; ++i)
            if (matchX[i] == 0) match(i);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (matchX[i] != 0) ++ans;
        old_matchX[i] = matchX[i];
    }
    cout << "Heap " << tests << '\n';

    bool ok = false;
    for (int i = 1; i <= n; ++i) {
        memset(matchX, 0, sizeof(matchX));
        memset(matchY, 0, sizeof(matchY));
        memset(dist, 0, sizeof(dist));
        if (old_matchX[i] == 0) continue;

        for (int i = 1; i <= n; ++i) adj[i].clear();

        for (int u = 1; u <= n; ++u) {
            for (int v : g[u]) {
                if (u == i && v == old_matchX[u]) continue;
                adj[u].push_back(v);
            }
        }

        while (findPath()) {
            for (int i = 1; i <= n; ++i)
                if (matchX[i] == 0) match(i);
        }
        int cnt = 0;
        for (int i = 1; i <= n; ++i) {
            if (matchX[i] != 0) ++cnt;
        }

        if (cnt != ans) {
            cout << '(' << char('A' + i - 1) << ',' << old_matchX[i] << ")  ";
            ok = true;
        }
    }
    if (ok == false) cout << "none";
    cout <<"\n\n";

    for (int i = 1; i <= n; ++i) {
        g[i].clear();
        adj[i].clear();
    }
    memset(matchX, 0, sizeof(matchX));
    memset(matchY, 0, sizeof(matchY));
    memset(dist, 0, sizeof(dist));
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);

    freopen("doanstt.inp", "r", stdin);
    freopen("doanstt.out", "w", stdout);

    while (cin >> n) {
        if (n == 0) break;
        ++tests;
        solve();
    }

    return 0;
}


paraphrase this code