#include <stdio.h> int main() { int a[10001],b[10001],g[10001],k[10001]; int n; scanf("%d",&n); int i; for(i=1;i<=n;i++) scanf("%d %d %d %d",&a[i],&b[i],&g[i],&k[i]); int x,y; scanf("%d %d",&x,&y); for(i=n;i>=1;i--) { if((x>=a[i])&&(x<=a[i]+g[i])&&(y>=b[i])&&(y<=b[i]+k[i])) { printf("%d",i); return 0; } } printf("-1"); return 0; }