problem
solution
codes
#include<iostream>
using namespace std;
int a[10010], b[10010], g[10010], k[10010];
int main(){
int n; cin>>n;
for(int i = 1; i <= n; i++)cin>>a[i]>>b[i]>>g[i]>>k[i];
int x, y; cin>>x>>y;
for(int i = n; i > 0; i--){
if(a[i]<=x && b[i]<=y && a[i]+g[i]>=x && b[i]+k[i]>=y){
cout<<i; return 0;
}
}
cout<<"-1";
return 0;
}