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