#include <iostream>
#include<cstring>
using namespace std;
int arr[10010][4];
int main()
{
memset(arr, -1, sizeof(arr));
int n, x, y, a, b, x0, y0, k = 1;;
cin >> n;
while (n) {
cin >> x >> y >> a >> b;
n--;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= b; j++) {
arr[x + i][y + j] = k;
}
}
k++;
}
cin >> x0 >> y0;
cout << arr[x0][y0];
return 0;
}