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

typedef long long ll;

int w[100][4];

int main() {
  ios::sync_with_stdio(0);
  int n, t = 1;
  while (cin >> n && n) {
    cout << "Desktop " << t++ << ":\n";
    for (int i = 0; i < n; i++)
      for (int j = 0; j < 4; j++)
        cin >> w[i][j];
    int m; cin >> m;
    for (int i = 0; i < m; i++) {
      int cr, cc; cin >> cr >> cc;
      int j;
      for (j = n-1; j >= 0; j--) {
        if (w[j][0] <= cr && cr < w[j][0]+w[j][3] && w[j][1] <= cc && cc < w[j][1]+w[j][2]) {
          cout << "window " << j+1 << "\n";
          break;
        }
      }
      if (j == -1)
        cout << "background\n";
    }
  }
  return 0;
}