// Arup Guha
// 8/3/2026
// Solution to 1990 UCF HS Programming Contest Problem: Keyed Up

import java.util.*;

public class mouse {
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);	
		while (stdin.hasNext()) {
		
			// get # of keys and # of clicks
			int nKeys = stdin.nextInt();
			int nClicks = stdin.nextInt();

			// Read keys first.
			ArrayList<key> keyList = new ArrayList<key>();
			for (int i=0; i<nKeys; i++) {
			
				// They should have been more clear that this wasn't going to be
				// some strange character where this messes up. I will only make
				// data with letters and digits and symbols that read properly.
				char c = stdin.next().charAt(0);
				
				// Get coordinates.
				int topX = stdin.nextInt();
				int topY = stdin.nextInt();
				
				// Make and add key.
				keyList.add(new key(c, topX, topY));
			}
			
			// Process clicks.
			for (int i=0; i<nClicks; i++) {
				int x = stdin.nextInt();
				int y = stdin.nextInt();
				Character ch = match(keyList, x, y);
				
				// No match.
				if (ch == null) {
					System.out.println("BOING!  The coordinate ("+x+", "+y+") does not correspond to a key.");
				}
				
				// Print in their format.
				else {
					System.out.println("Beep.  The key selected at coordinate ("+x+", "+y+") had \""+ch+"\" on it.");
				}
			}
			
			// After each case.
			System.out.println();
		}
	}
	
	public static Character match(ArrayList<key> list, int x, int y) {
		
		// Go through each key and return if there's a match.
		for (key k: list) 
			if (k.hit(x, y))
				return k.ch;
		
		// No match.
		return null;
	}
}

class key {

	final public static int LEN = 250;
	
	public Character ch;
	public int topX;
	public int topY;
	
	// Basic constructor.
	public key(char c, int x, int y) {
		ch = c;
		topX = x;
		topY = y;
	}

	// There are 250 integers from x to x+49...That's why we use >= and <.
	public boolean hit(int x, int y) {
		return x>=topX && y>=topY && x<topX+LEN && y<topY+LEN;
	}
}