//*******************************************************************************#include #include #include #include using namespace std;#define eps 1e-8int dcmp(double x){ if(fabs(x) 0)return false;//交点不在线段AB上 p=A+(B-A)*t; //计算交点 return PointInTri(p,p0,p1,p2); //判断交点是否在三角形内 }}/*到直线的距离double DistanceToLine(Point3 p,Point3 A,Point3 B){ Vector3 v1=B-A,v2=p-A; return Length(Cross(v1,v2))/Length(v1);}//点p到线段AB的距离double DistanceToSegment(Point3 p,Point3 A,Point3 B){ if(A==B)return Length(p-A); Vector3 v1=B-A,v2=p-A,v3=p-B; if(dcmp(Dot(v1,v2))<0)return Length(v2); else if(dcmp(Dot(v1,v3))>0)return Length(v3); else return Length(Cross(v1,v2))/Length(v1);}//返回,,的混合积,他等于四面体邮箱面积的6倍double Volume6(Point3 A,Point3 B,Point3 C,Point3 D){ return Dot(D-A,Cross(B-A,C-A));}*///判断两个三角形是否有公共点bool TriTriIntersection(Point3* T1,Point3* T2){ Point3 p; for(int i=0;i<3;i++){ if(TriSegIntersection(T1[0],T1[1],T1[2],T2[i],T2[(i+1)%3],p))return true; if(TriSegIntersection(T2[0],T2[1],T2[2],T1[i],T1[(i+1)%3],p))return true; } return false;}//*******************************************************************************int main(){ int T;cin>>T; while(T--){ Point3 T1[3],T2[3]; for(int i=0;i<3;i++)cin>>T1[i].x>>T1[i].y>>T1[i].z; for(int i=0;i<3;i++)cin>>T2[i].x>>T2[i].y>>T2[i].z; cout<<(TriTriIntersection(T1,T2) ? "1\n":"0\n"); }return 0;}//*******************************************************************************