import java.util.Scanner;
public class Main{
public static class Node{
int x1,y1,x2,y2,num;
public Node(int x1, int y1, int x2, int y2,int num) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.num = num;
}
}
static Node stack[] = new Node[25];
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int base = 0,top = -1;
int n = scanner.nextInt();
int m = scanner.nextInt();
int j = 1;
while(n-->0) {
int x1 = scanner.nextInt();
int y1 = scanner.nextInt();
int x2 = scanner.nextInt();
int y2 = scanner.nextInt();
stack[++top] = new Node(x1,y1,x2,y2,j++);//用栈来保存每一个窗口的信息
}
while(m-->0) {
int x = scanner.nextInt();
int y = scanner.nextInt();
int i = top;
while(i!=-1) {
if(check(stack[i],x,y)) {//若点击到了窗口,则将此窗口移到栈顶
stack[++top] = stack[i];
System.out.println(stack[i].num);
break;
}
i--;
}
if(i==-1) System.out.println("IGNORED");//整个栈找不到就打印错误信息
}
}
private static boolean check(Node node, int x, int y) {
if(x>=node.x1&&x<=node.x2&&y>=node.y1&&y<=node.y2) return true;
return false;
}
}
网友评论