#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int n,x[5][10010],y[5][10010];
int xx,yy;
int find(){
int i;
for (i=n;i>0;i--)
if (xx>=x[1][i]&&xx<=x[2][i]&&yy>=y[1][i]&&yy<=y[2][i])
return i;
return -1;
}
int main(){
int i,a,b;
freopen("carpet.in","r",stdin);
freopen("carpet.out","w",stdout);
scanf ("%d",&n);
for (i=1;i<=n;i++){
scanf( "%d%d%d%d", x[1]+i,y[1]+i,&a, &b );
x[2][i]=x[1][i]+a;
y[2][i]=y[1][i]+b;
}
scanf ("%d%d",&xx,&yy);
printf("%d\n",find());
return 0;
}