#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a = -1;
cin >> n;
int x1[n], y1[n], x2[n], y2[n], x, y;
for (int i = 0; i < n; i++) {
cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
}
cin >> x >> y;
for (int i = 0; i < n; i++) {
if (x1[i] <= x && y1[i] <= y && x2[i] >= x && y2[i] >= y) {
a = i + 1;
}
}
cout << a;
return 0;
}