/* Solution to windows
 */
import java.util.*;

class Window {
  public int ulr, ulc, width,height;
  public Window (int r, int c, int w, int h) {
    ulr = r; ulc = c; width = w; height = h;
  }
}

public class Windows {
  public static int n,m;
  public static Window w[];
  public static ArrayList<Window> stack;
  public static Scanner in;
  public static int desktop;

  public static void main(String[] args) {
    in = new Scanner(System.in);
    desktop = 0;

    while (true) {
      n = in.nextInt();
      if (n == 0) break;
      desktop++;
      stack = new ArrayList<Window>();
      for (int i = 0; i < n; i++) {
        int ulr = in.nextInt();
        int ulc = in.nextInt();
        int w = in.nextInt();
        int h = in.nextInt();
        stack.add(new Window(ulr,ulc,w,h));
      }

      System.out.println("Desktop " + desktop + ":");
      m = in.nextInt();
      for (int i = 0; i < m; i++) {
        int r = in.nextInt();
        int c = in.nextInt();
        int j = 0;
        for (j = stack.size()-1; j >= 0; j--) {
          Window win = stack.get(j);
          if (contains(win,r,c)) break;
        }
        if (j >= 0)
          System.out.println("window " + (j+1));
        else
          System.out.println("background");
      }
    }
  }

  public static boolean contains(Window w, int r, int c) {
    return (r >= w.ulr && r <= w.ulr + w.height-1 && 
            c >= w.ulc && c <= w.ulc + w.width-1);
  }
}
