#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct{
    int x;
    int y;
}XY;

int main(void){
    int i;
    
    int n;
    scanf("%d\n",&n);

    XY xy[n];
    for(i=0;i<n;i++)scanf("%d %d\n",&xy[i].x,&xy[i].y);
    
    int q;
    scanf("%d\n",&q);
    
    int sx,tx,sy,ty;
    while(q--){
        scanf("%d %d %d %d\n",&sx,&tx,&sy,&ty);
        for(i=0;i<n;i++){
            if(sx<=xy[i].x&&xy[i].x<=tx&&sy<=xy[i].y&&xy[i].y<=ty)printf("%d\n",i);
        }
        printf("\n");
    }
    
    return 0;
}

