#include<stdio.h>
int cpll(int  p0[2],int p1[2],int p2[2],int p3[2],double *x,double *y){
  int a=p1[0]-p0[0],c=p2[0]-p0[0],e=p3[0]-p2[0];
  int b=p1[1]-p0[1],d=p2[1]-p0[1],f=p3[1]-p2[1];
  if(b*e-a*f==0)return 0;
  *x=p2[0]+1.0*e*(a*d-b*c)/(b*e-a*f);
  *y=p2[1]+1.0*f*(a*d-b*c)/(b*e-a*f);
  return 1;
}
int main(){
  int p[4][2],n,i;
  double x,y;
  scanf("%d",&n);
  while(n--){
    for(i=0;i<8;i++)scanf("%d",&p[i/2][i%2]);
    if(cpll(p[0],p[1],p[2],p[3],&x,&y))printf("%.9f %0.9f\n",x,y);
  }
  return 0;
}