/*
TASK: mov
LANG: C++
*/
#include <iostream>
#define m 2000000
using namespace std;

struct point{long long x,y;};
point a,b,c,d,v,p,q;
double k,t;
int x,y,z,out,n,i;

int ccw(point p1,point p2,point p3)
{long long l;
l=(p2.y-p3.y)*p1.x+(p3.x-p2.x)*p1.y+p1.x*p3.y+p2.y+p3.x;
if (l==0) return 0;
if (l>0) return 1;
if (l<0) return -1;
}
int main()
{
cin>>n;	
for(i=0;i<n;i++)
{	
cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y>>v.x>>v.y;
k=0;
if (v.x!=0) {
	         t=(m-b.x)/(double)v.x;
	         if (t>k)k=t;
	         t=(m-a.x)/(double)v.x;
	         if (t>k)k=t;
			 t=(-m-b.x)/(double)v.x;
	         if (t>k)k=t;
	         t=(-m-a.x)/(double)v.x;
	         if (t>k)k=t;
		    }	
if (v.y!=0) {
	         t=(m-b.y)/(double)v.y;
	         if (t>k)k=t;
	         t=(m-a.y)/(double)v.y;
	         if (t>k)k=t;
			 t=(-m-b.y)/(double)v.y;
	         if (t>k)k=t;
	         t=(-m-a.y)/(double)v.y;
	         if (t>k)k=t;
		    }
p.x=a.x+(int)(v.x*k);
p.y=a.y+(int)(v.y*k);
q.x=b.x+(int)(v.x*k);
q.y=b.y+(int)(v.y*k);
out=0;
x=ccw(a,c,p);
y=ccw(b,c,a);
z=ccw(q,c,b);
if (x==y&&y==z) out=1; 
if ((x*y*z)==0) out=1;
x=ccw(a,d,p);
y=ccw(b,d,a);
z=ccw(q,d,b);
if (x==y&&y==z) out=1; 
if ((x*y*z)==0) out=1;
cout<<out;
}
cout<<endl;	
//system("pause");
return 0;
}
