#include<stdio.h>
#include <stdlib.h>
struct z {
int a;
int b;
int g;
int k;
};
int main(){
int n,x,y;
scanf("%d",&n);
struct z *m;
m=(struct z*)malloc(n*sizeof(struct z));
for(int c=0;c<n;c++){
scanf("%d %d %d %d",&m[c].a,&m[c].b,&m[c].g,&m[c].k);
printf("\n");
}
scanf("%d %d",&x,&y);int l=0;
for(int h=n-1;h>=0;h--){
if(m[h].a <= x && x < m[h].a + m[h].g && m[h].b <= y && y < m[h].b + m[h].k){
printf("%d",h+1);l=1;
break;
}
}
if(l==0){printf("%d",-1);}
free(m);
}