#include <bits/stdc++.h>
#define debug freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)
using namespace std;
const int N=10000+5;
int a[N],b[N],g[N],k[N];
int n,x,y;
int ans=-1;
void work()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d%d%d",&a[i],&b[i],&g[i],&k[i]);
scanf("%d%d",&x,&y);
for(int i=1;i<=n;i++)
if(x>=a[i]&&y>=b[i]&&x<=a[i]+g[i]&&y<=b[i]+k[i])
ans=i;
printf("%d",ans);
}
int main()
{
//debug;
work();
return 0;
}