#include <cstdio>
using namespace std;
int n,ax,ay;
int x[10001];
int y[10001];
int xx[10001];
int yy[10001];
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",&x[i],&y[i],&xx[i],&yy[i]);
xx[i]=xx[i]+x[i];
yy[i]=yy[i]+y[i];
}
scanf("%d%d",&ax,&ay);
for (int i=n;i>0;i--)
{
if (ax>=x[i]&&ax<=xx[i]&&ay>=y[i]&&ay<=yy[i])
{
printf("%d\n",i);
return(0);
}
}
printf("-1\n");
return(0);
}