#include <bits/stdtr1c++.h>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<ld> pt;

struct window {
	int r, c, w, h;
};

int main() {
	ios::sync_with_stdio(0);
	int n; 
	while (cin >> n) {
		if (!n) break;
		
		vector<window> v;
		for (int i = 0; i < n; i++) {
			int r, c, w, h; cin >> r >> c >> w >> h;
			v.push_back({r, c, w, h});
		}
		
		static int ca = 1;
		cout << "Desktop " << ca++ << ":" << endl;
		int m; cin >> m;
		while (m--) {
			int x, y; cin >> x >> y;
			bool found = false;
			for (int i = v.size()-1; i >= 0; i--) {
				if (x >= v[i].r && x < v[i].r + v[i].h && y >= v[i].c && y < v[i].c + v[i].w) {
					cout << "window " << i+1 << endl;
					found = true;
					break;
				}
			}
			if (!found) cout << "background" << endl;
		}
	}
	return 0;
}