var
a,b,g,k:array[1..10000]of longint;
n,x,y,c,d:longint;
begin
assign(input,'carpet.in');
assign(output,'carpet.out');
reset(input);
rewrite(output);
readln(n);
for d:=1 to n do
readln(a[d],b[d],g[d],k[d]);
readln(x,y);
for d:=n downto 1 do
if (x-a[d]<=g[d])and(x-a[d]>=0)and(y-b[d]>=0)and(y-b[d]<=k[d])then
begin
write(d);exit;
end;
if c=0 then write('-1');
close(input);close(output);
end.