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