抄模版1A
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#define LL long long
#define DB double
using namespace std;
const DB EPS = 1e-8;
const DB PI = acos(-1.0);
struct cpoint{
DB x,y,R;
void get(){scanf("%lf%lf",&x,&y);}
void out(){cout<<x<<" "<<y<<endl;}
};
struct cvector{
DB x,y;
cvector(DB a=0,DB b=0){x=a;y=b;}
};
struct csegment{
cpoint st,en;
csegment(cpoint a,cpoint b){st=a;en=b;}
csegment(){}
};
cvector operator-(cpoint a,cpoint b)
{
return cvector(a.x-b.x,a.y-b.y);
}
cpoint operator+(cpoint a,cvector b)
{
a.x+=b.x;a.y+=b.y;
return a;
}
DB dot(cvector a,cvector b)
{
return a.x*b.x+a.y*b.y;
}
DB length(cvector a)
{
return sqrt(a.x*a.x+a.y*a.y);
}
DB alph;
cpoint O,M,P,A,B;
void in()
{
O.get();M.get();
scanf("%lf%lf",&alph,&O.R);
P.get();scanf("%lf",&P.R);
}
DB get_angl(cpoint a,cpoint b,cpoint p)
{
return acos(dot(a-p,b-p)/(length(a-p)*length(b-p)));
}
cpoint p2seg(cpoint p,csegment s){
cpoint ret=s.st;
double len = length(s.en-s.st);
double t1=dot((p-s.st),(s.en-s.st))/len;//投影长度
if(t1>-EPS&&t1<len+EPS){//小于线段长度
cvector v = s.en-s.st;
ret.x+=v.x*t1/len;ret.y+=v.y*t1/len;
return ret;
}
if(t1<0) return s.st;
else return s.en;
}
DB dist(cpoint a,cpoint b)
{
return length(a-b);
}
cvector rotation(cvector a,double alpha){
cvector p;
p.x = a.x*cos(alpha)-a.y*sin(alpha);
p.y = a.y*cos(alpha)+a.x*sin(alpha);
return p;
}
cvector unit(cvector t)
{
DB l = length(t);
t.x/=l;t.y/=l;
return t;
}
void get_AB(DB ag)
{
cvector tmp = unit(M-O);
tmp.x*=O.R;tmp.y*=O.R;
A = O+rotation(tmp,ag);
B = O+rotation(tmp,-ag);
}
void solve()
{
DB angl = get_angl(M,P,O);
DB ag = alph*PI/180/2;
get_AB(ag);
if(angl>ag)
{
cpoint tmp1 = p2seg(P,csegment(O,B));
cpoint tmp2 = p2seg(P,csegment(O,A));
DB d = min(dist(tmp1,P),dist(tmp2,P));
if(d<P.R+EPS)
{
printf("1\n");
}else
{
printf("0\n");
}
}else
{
DB d = dist(O,P);
if(d<O.R+P.R+EPS)
{
printf("1\n");
}else
{
printf("0\n");
}
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int cas;scanf("%d",&cas);
while(cas--)
{
in();
solve();
}
return 0;
}