// Time 234 ms; Memory 244 K
#include #include #include using namespace std;typedef struct point{ double x,y,z; point(double xx=0,double yy=0,double zz=0):x(xx),y(yy),z(zz){}}vector;vector operator - (point a,point b){ return vector(a.x-b.x,a.y-b.y,a.z-b.z);}point operator + (point a,vector b){ return point(a.x+b.x,a.y+b.y,a.z+b.z);}vector operator * (vector a,double b){ return vector(a.x*b,a.y*b,a.z*b);}double dot(vector a,vector b){ return a.x*b.x+a.y*b.y+a.z*b.z;}double len(vector a){ return sqrt(dot(a,a));}vector cross(vector a,vector b){ return vector(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);}point inter(point a,point b,point c,point d,point e){ point fa=cross(b-a,c-a); double t=dot(fa,a-d)/dot(fa,e-d); return d+(e-d)*t;}vector resize(vector a,double b){ b/=len(a); return a*b;}point ptol(point o,point a,point b){ point fa=cross(a-o,b-o); point vec=cross(b-a,fa); return o+resize(vec,len(fa)/len(b-a));}void gc(point a,point b,point c,point d,point &p1,point &p2){ point e=d+cross(a-b,c-d); p1=inter(c,d,e,a,b); p2=ptol(p1,c,d);}int main(){ int t; point a,b,c,d,p,q; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&a.z,&b.x,&b.y,&b.z); scanf("%lf%lf%lf%lf%lf%lf",&c.x,&c.y,&c.z,&d.x,&d.y,&d.z); gc(a,b,c,d,p,q); double l=len(p-q); printf("%.6lf\n",l); printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",p.x,p.y,p.z,q.x,q.y,q.z); } return 0;}