#include
int main()
{
long int n;
long int a[10000][4];
long int x,y;
int num=0;
scanf("%ld",&n);
for (int i = 0; i < n;i++)
scanf("%ld%ld%ld%ld",&a[i][0],&a[i][1],&a[i][2],&a[i][3]);
scanf("%ld%ld",&x,&y);
for (int i = 0; i < n; i++)
if (x>=a[i][0]&&x<=a[i][2]+a[i][0]&&y>=a[i][1]&&y<=a[i][1]+a[i][3])
num =i+1;
if (num==0) printf("-1");
else printf("%ld",num);
return 0;
}