#include<cstdio>
using namespace std;
struct area
{
int xa;
int xb;
int ya;
int yb;
};
area h[10010];
int n;
int tot=-1;
int x,y,sx,sy;
int main()
{
freopen("carpet.in","r",stdin);
freopen("carpet.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%d%d%d%d",&h[i].xa,&h[i].ya,&x,&y);
h[i].xb=h[i].xa+x;
h[i].yb=h[i].ya+y;
}
scanf("%d%d",&sx,&sy);
for(int i=n;i>=1;--i)
{
if(sx>=h[i].xa&&sx<=h[i].xb)
{
if(sy>=h[i].ya&&sy<=h[i].yb)
{
tot=i;
break;
}
}
}
printf("%d",tot);
return 0;
}