#include <vector>
#include <iostream>
struct Geometry
{
int x;
int y;
int w;
int h;
};
struct Coord
{
int x;
int y;
};
void blanket()
{
int n = 0;
std::cin >> n;
std::vector<Geometry> vec;
for (int i = 0; i < n; i++)
{
Geometry geo;
std::cin >> geo.x >> geo.y >> geo.w >> geo.h;
vec.push_back(geo);
}
Coord target;
std::cin >> target.x >> target.y;
int count = 0;
int index = -1;
for (int i = 0; i < n; i++)
{
if (vec[i].x <= target.x &&
vec[i].y <= target.y &&
vec[i].x + vec[i].w >= target.x &&
vec[i].y + vec[i].h >= target.y)
index = i + 1;
}
std::cout << index << std::endl;
}
int main()
{
blanket();
return 0;
}