#include <stdio.h>
#include<stdlib.h>
struct point {
long x,y,xl,yl,count ;
struct point * next;
};
int main() {
long all=0;
long ans=-1;
struct point old,start;
struct point target;
scanf("%ld",&all);
struct point* new =(struct point *)malloc(sizeof(struct point));
start=new ;
for(int a=1;a<=all;a++){
scanf("%ld",&(new->x));
scanf("%ld",&(new->y));
scanf("%ld",&(new->xl));
scanf("%ld",&(new->yl));
new->count=a;
old =new;
new =(struct point *)malloc(sizeof(struct point));
old->next=new;
}
old->next=NULL;
free(new);
scanf("%ld",&target.x);
scanf("%ld",&target.y);
do{
if(target.x>=start->x&&target.x<=(start->xl+start->x)&&target.y>=start->y&&target.y<=(start->yl+start->y)){
ans =start->count;
}
old = start;
start=start->next;
free(old);
}while(start!=NULL);
printf("%ld",ans);
return 0;
}