import java.util.Scanner;

public class D {	
	
	public static int search(int[][] arr, int x, int y){
		for (int i = arr.length - 1; i >= 0; i--){
			if (x >= arr[i][0] && x <= arr[i][0] + arr[i][3] - 1 && y >= arr[i][1] && y <= arr[i][1] + arr[i][2] - 1){
				return i + 1;
			}
		}
		return 0;
	}
	
	public static void main (String [] args){
		Scanner scan = new Scanner (System.in);
		
		int testNo = 1;
		while (true){
			int n = scan.nextInt();
			if (n == 0){
				break;
			}
			
			int [][] windows = new int[n][4];
			
			for (int i = 0; i < windows.length; i++){
				for (int j = 0; j < 4; j++){
					windows[i][j] = scan.nextInt();
				}
			}
			
			int q = scan.nextInt();
			System.out.println("Desktop " + testNo + ":");
			
			for (int i = 0; i < q; i++){
				int x = scan.nextInt();
				int y = scan.nextInt();
				
				int result = search(windows, x, y);
				
				if (result == 0){
					System.out.println("background");
				}
				else {
					System.out.println("window " + result);
				}
			}
			testNo++;
		}
		scan.close();
	}
}