T1:
#include<stdio.h>
#include<stdlib.h>
inline int gi(){
int sum=0,f=1;char ch=getchar();
while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0' && ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
return sum*f;
}
const int maxn=100010;
int a[maxn],b[maxn],g[maxn],k[maxn];
int main(){
int i,j,n,m,x,y;
n=gi();
for(i=1;i<=n;i++){
a[i]=gi();b[i]=gi();g[i]=gi();k[i]=gi();
}
x=gi(),y=gi();
for(i=n;i>=1;i--){
if(x>=a[i] && x<=a[i]+g[i] && y>=b[i] && y<=b[i]+k[i]){
printf("%d
",i);return 0;
}
}
puts("-1");
return 0;
}