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