#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
#define eps 1e-6
struct Node
{
double x,y,z;
}line[2];
double chaji(Node a,Node b)//计算两个向量的叉积
{
double x1=a.x;
double y1=a.y;
double z1=a.z;
double x2=b.x;
double y2=b.y;
double z2=b.z;
double x=y1*z2-z1*y2;
double y=z1*x2-x1*z2;
double z=x1*y2-y1*x2;
return sqrt(x*x+y*y+z*z);
}
int main()
{
double h1,r1,x1,y1,z1;
double h2,r2,x2,y2,z2,x3,y3,z3;
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf%lf",&h1,&r1,&x1,&y1,&z1);
scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&h2,&r2,&x2,&y2,&z2,&x3,&y3,&z3);
line[0].x=x3;line[0].y=y3;line[0].z=z3;
line[1].x=x1-x2;line[1].y=y1-y2;
line[1].z=z1+h1-r1-(h2*0.9+z2-r2);
double d=chaji(line[0],line[1]);
d/=sqrt(x3*x3+y3*y3+z3*z3);
if(d-r1<eps) printf("YES\n");
else printf("NO\n");
}
return 0;
}