#include<stdio.h>

int main()
{
    double a1,b1,a2,b2,a3,b3,a4,b4,n,i,x,y;
    scanf("%lf",&n);
    for(i=1;i<=n;i++){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a1,&b1,&a2,&b2,&a3,&b3,&a4,&b4);

    x=((((a2-a1)*(a3*b4-a4*b3))-((a4-a3)*(a1*b2-a2*b1)))*1/(((b1-b2)*(a4-a3))-((b3-b4)*(a2-a1))));
    y=((((a2-a1)*(a3*b4-a4*b3))-((a4-a3)*(a1*b2-a2*b1)))*1/(((b1-b2)*(a4-a3))-((b3-b4)*(a2-a1))));

    printf("%.10lf\n",x);
    printf("%.10lf\n",y);

}
return 0;
}

