#include <iostream>
#include <fstream>
using namespace std;
const int MAXN(10001);
int n, x, y, a1[MAXN], a2[MAXN], b1[MAXN], b2[MAXN];
main()
{
ifstream fin("carpet.in");
ofstream fout("carpet.out");
//#define fin cin
//#define fout cout
fin >> n;
for (int i = 1; i <= n; ++i){
int a, b, g, k;
fin >> a >> b >> g >> k;
a1[i] = a;
b1[i] = b;
a2[i] = a + g;
b2[i] = b + k;
}
fin >> x >> y;
for (int i = n; i >= 1; --i)
if(x>=a1[i]&&x<=a2[i]&&y>=b1[i]&&y<=b2[i]){
fout << i;
return 0;
}
fout << -1;
}