#include<bits/stdc++.h>
using namespace std;
int op[10005][5390];
int main(){
int n,x,y;
cin>>n;
for(int i=1;i<=n;i++){
int a,b,g,k;
cin>>a>>b>>g>>k;
for(int j=a;j<=a+g;j++){
for(int x=b;x<=b+k;x++){
op[j][x]=i;
}
}
}
cin>>x>>y;
if(op[x][y]==0){
cout<<-1<<endl;
}
else{
cout<<op[x][y]<<endl;
}
return 0;
}