#include<iostream>
using namespace std;
int main()
{
int n = 0;
cin >> n;
int a[10000][4];
for (int i = 0; i < n; ++i)
{
cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
}
int x, y;
cin >> x >> y;
int num = 0;
for (int i = 0; i < n; ++i)
{
if (x >= a[i][0] && x <= a[i][0] + a[i][2] && y >= a[i][1] && y <= a[i][1] + a[i][3])
{
num = i + 1;
}
}
if (num != 0)
{
cout << num;
}
else
{
cout << "-1";
}
}