#include<bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
struct pet{  //地毯结构体
	int a,b,g,k;
}p[N];

int main(){
	int n;  cin >> n;
	for(int i=1 ; i <=n ; i++){
		cin >> p[i].a >> p[i].b >> p[i].g >> p[i].k;
	}
	int x,y;  cin >> x >> y;
	int ans = 0;
	for(int i=n ; i >= 1 ; i--){//从后往前遍历,找到就退出
		int x1 = p[i].a, x2 = p[i].a + p[i].g;
		int y1 = p[i].b, y2 = p[i].b + p[i].k;
		if(x >=x1 &&x <=x2 &&y >= y1 &&y <= y2){ //要求的点在地毯范围内
			ans = i;
			break;
		}
	}
	if(ans == 0) cout << -1;
	else cout << ans;
    return 0;
}