#include<iostream>
using namespace std;
bool judge(int x0,int y0,int dx,int dy, int a,int b){
if((x0<=a&&a<=x0+dx)&&(y0<=b&&b<=y0+dy)){
return true;
}
else{
return false;
}
}
int main(){
unsigned int n, x, y, a, b, i;
unsigned int pos[10005][3];
std::ios::sync_with_stdio(false);
cin >> n;
for(i=1;i<=n;i++){
cin >> pos[i][0];
cin >> pos[i][1];
cin >> pos[i][2];
cin >> pos[i][3];
}
cin >> a >> b;
for(i=n;i>=1;i--){
if(judge(pos[i][0],pos[i][1],pos[i][2],pos[i][3],a,b)){
cout << i << endl;
return 0;
}
}
cout << -1 << endl;
return 0;
}