#include <vector>
#include <iostream>
using namespace std;
/*
先把所有地毯的坐标储存起来
因为后面的地毯覆盖在前面的地毯上
所以,如果有多个包含点(x,y)的地毯,就输出最后一个
也就是反向遍历
如果符合条件,就退出
否则,继续检查当前地毯的前一个地毯
*/

//定义一个vector,v的每一个元素都是两个点,前一个点表示地毯的左下角的坐标,后一个点是地毯的右上角的坐标
vector<pair<pair<int, int>, pair<int, int>>> v;
void solve() {
    int n;
    cin >> n;
    int i = n;
    v.reserve(n);
    int a, b, g, k;
    while (n--) {
	  // 把地毯的左下角的点和右上角的点储存至容器中
        cin >> a >> b >> g >> k;
        pair<pair<int, int>, pair<int, int>> elem = {{a, b}, {a + g, b + k}};
        v.push_back(elem);
    }

    int x, y, x1, y1, x2, y2;
    cin >> x >> y;
  
  //反向迭代
    for (vector<pair<pair<int, int>, pair<int, int>>>::reverse_iterator it =
                v.rbegin();
            it != v.rend(); it++) {
        x1 = (*it).first.first;
        y1 = (*it).first.second;
        x2 = (*it).second.first;
        y2 = (*it).second.second;
        if (
            ((x1 <= x) && (x <= x2)) && ((y1 <= y) && (y <= y2))
        ) {
		  // 如果(x,y)并且在(x1,y1)和(x2,y2)范围内(含边界和顶点)
		  // 就输出这个地毯的编号
            cout << i;
            break;
        } else {
		  // 否则,继续检查前一个地毯
            i -= 1;
        }
    }
	if(i==0){
	  //如果最后一个地毯仍然不符合条件(此时经过i次i--,i已经是0)
        cout << -1;
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    solve();
}
// 64 位输出请用 printf("%lld")