import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
// x[i][0]和x[i][1]分别放x,y,x[i][3]表示这是第几个窗口,便于输出
int[][] x = new int[n][3];
int[][] y = new int[n][2];
for (int i = 0; i < n; i++) {
x[i][0] = scanner.nextInt();
y[i][0] = scanner.nextInt();
x[i][1] = scanner.nextInt();
y[i][1] = scanner.nextInt();
x[i][2] = i+1;
}
for (int i = 0; i < m; i++) {
int xi = scanner.nextInt();
int yi = scanner.nextInt();
// flag的作用是,如果鼠标点击的位置没有窗口,输出ignored
boolean flag = true;
// 由于输入的窗口是从最底层到最顶层的,那么x[n-1]表示最顶层,鼠标点击窗口应该从最顶层往最底层遍历
for (int j = n-1; j >= 0; j--) {
if (xi >= x[j][0] && xi <= x[j][1] && yi >= y[j][0] && yi <= y[j][1]){
flag = false;
System.out.println(x[j][2]);
// 为了保持数组中窗口的优先级,需要把当前显示在屏幕最顶层的放到x[n-i]中
int[] tempt_x = x[j];
int[] tempt_y = y[j];
for (int k = j+1; k < n; k++){
x[k-1] = x[k];
y[k-1] = y[k];
}
x[n-1] = tempt_x;
y[n-1] = tempt_y;
break;
}
}
if (flag)
System.out.println("IGNORED");
}
}
}