program carpet;
var
x,y,i,m,n:longint;
x1,x2,y1,y2:array[1..10000]of longint;
procedure init;
begin
assign(input,'carpet.in');reset(input);
assign(output,'carpet.out');rewrite(output);
end;
procedure main;
begin
readln(n);
for i:=1 to n do
readln(x1[i],y1[i],x2[i],y2[i]);
readln(x,y);
for i:=n downto 1 do
if (x1[i]<=x)and(x1[i]+x2[i]>=x)and(y1[i]<=y)and(y2[i]+y1[i]>=y)
then begin
writeln(i);
exit;
end;
writeln(-1);
end;
procedure out;
begin
close(input);
close(output);
end;
begin
init;
main;
out;
end.//complete by hudie20140617