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

int desktop_num;
int main() {
  int n, m;
  int r, c, h, w, cr, cc;
  class Window {
   public:
    int r, c, w, h;
    Window(int r, int c, int w, int h) : r(r), c(c), w(w), h(h) {}
    bool inWindow(int r, int c) {
      return r >= this->r && c >= this->c && r < this->r + this->h && c < this->c + this->w;
    }
  };

  while (true) {
    cin >> n;
    if (n == 0) {
      break;
    }
    cout << "Desktop " << ++desktop_num << ":\n";
    vector<Window*> windows;
    while (n--) {
      cin >> r >> c >> w >> h;
      windows.push_back(new Window(r, c, w, h));
    }
    cin >> m;
    while (m--) {
      cin >> cr >> cc;
      int atWindow = 0;
      for (int i = 0; i < windows.size(); i++) {
        if (windows[i]->inWindow(cr, cc)) {
          atWindow = i + 1;
        }
      }
      if (atWindow == 0)
        cout << "background\n";
      else
        cout << "window " << atWindow << '\n';
    }

  }

  return 0;
}