#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define MAX_W 200000
using namespace std;
struct carpet {
int a, b, g, k;
};
vector<carpet> carpets;
int main(){
fstream in("carpet.in", ios::in), out("carpet.out", ios::out);
cin.rdbuf(in.rdbuf());
cout.rdbuf(out.rdbuf());
int n, x, y, t = -1;;
cin >> n;
for(int i = 1; i <= n; ++i){
int a, b, g, k;
cin >> a >> b >> g >> k;
carpet co = {a, b, g, k};
carpets.push_back(co);
}
cin >> x >> y;
for(unsigned i = 0; i < carpets.size(); ++i){
carpet co = carpets[i];
if(x >= co.a && y >= co.b && x <= co.a + co.g && y <= co.b + co.k)
t = i + 1;
}
cout << t << endl;
return 0;
}