#include
using namespace std;
int main() {
int n;
cin >> n;
int a[1000], b[1000], c[1000], d[1000];
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i] >> c[i] >> d[i];
}
int x, y;
cin >> x >> y;
for (int i = n; i >=1 ; i--) {
if (x >= a[n] && x <= a[n] + c[n])
if (y >= b[n] && y <= b[n] + d[n]) {
cout << i;
return 0;
}
}
cout << -1;
return 0;
}