Program p1;
var kp,tkp,ans:byte;
    v1,v2,l1,l2,x1,y1,x2,y2:real;
procedure vv;
begin
   read(v1,v2,l1,l2,x1,y1,x2,y2);
end;

procedure re;
 var t1,t2,t3,t4:real;
begin
   if x1=0 then x1:=y1;
   if y2=0 then y2:=x2;
   t1:=x1/v1;
   t2:=(x1+l1)/v1;
   t3:=y2/v2;
   t4:=(y2+l2)/v2;
   if (t2<=t3)or(t1>=t4)
       then ans:=0
       else ans:=1;
end;

procedure viv;
begin
   write(ans);
end;
Begin
     read(kp);
     for tkp:=1 to kp
       do begin
           vv;
           re;
           viv;
         end;
End.