#include <bits/stdc++.h>
using namespace std;
int n;
int a;
int b;
int g;
int k;
int x;
int y;
int f[10001][10001];
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a >> b >> g >> k;
for (int j = a; j <= a + g; ++j) {
for (int l = b; l <= b + k; l++) {
f[j][l] = i;
}
}
}
cin >> x >> y;
if (!f[x][y]) {
cout << -1 << endl;
}
cout << f[x][y] << endl;
return 0;
}