#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

#define endl '\n'

int main() {
	ios::sync_with_stdio(0);
	int n;
	int T = 1;
	while(cin >> n && n!=0) {
		cout << "Desktop " << T << ":" << endl;
		vector<pair<pii,pii>> inp;
		for (int i=0; i<n; i++) {
			int r,c,w,h;
			cin >> r >> c >> w >> h;
			inp.push_back(pair<pii,pii>(pii(r,c),pii(w,h)));
		}
		int m; cin >> m;
		while(m--) {
			int x, y; cin >> x >> y;
			int ans = -1;
			for (int i=0; i<n; i++) {
				if (x >= inp[i].first.first &&
					y >= inp[i].first.second &&
					x < (inp[i].first.first + inp[i].second.second) &&
					y < (inp[i].first.second + inp[i].second.first) )
					ans = i+1;
			}
			if (ans == -1) {
				cout << "background" << endl;
			} else {
				cout << "window " << ans << endl;
			}
		}
		T++;
	}
	return 0;
}