#include<bits/stdc++.h>
using namespace std;
struct node{
int x,y;
};
struct fang{
node a,b,c,d;
};
double k1,k2;
void func(int a,int b,int c,int d,int m,int n){
k1 = (double)((m*d-n*b)*1.0) / (a*d - b * c);
k2 = (double)(n-(c*k1)*1.0)/d;
return ;
}
int main(){
int T;
scanf("%d",&T);
while(T--){
fang mp1,mp2;
cin>>mp1.a.x>>mp1.a.y;
cin>>mp1.b.x>>mp1.b.y;
cin>>mp1.c.x>>mp1.c.y;
cin>>mp1.d.x>>mp1.d.y;
cin>>mp2.a.x>>mp2.a.y;
cin>>mp2.b.x>>mp2.b.y;
cin>>mp2.c.x>>mp2.c.y;
cin>>mp2.d.x>>mp2.d.y;
node AB,AD,ab,ad;
AB.x=mp1.b.x-mp1.a.x;
AB.y=mp1.b.y-mp1.a.y;
AD.x=mp1.d.x-mp1.a.x;
AD.y=mp1.d.y-mp1.a.y;
ab.x=mp2.b.x-mp2.a.x;
ab.y=mp2.b.y-mp2.a.y;
ad.x=mp2.d.x-mp2.a.x;
ad.y=mp2.d.y-mp2.a.y;
node A,B;
A.x=AB.x-ab.x;
A.y=AB.y-ab.y;
B.x=AD.x-ad.x;
B.y=AD.y-ad.y;
node Aa;
Aa.x=mp2.a.x-mp1.a.x;
Aa.y=mp2.a.y-mp1.a.y;
func(A.x,B.x,A.y,B.y,Aa.x,Aa.y);
double ansx=k1*AB.x+k2*AD.x+mp1.a.x;
double ansy=k1*AB.y+k2*AD.y+mp1.a.y;
printf("%.6lf %.6lf",ansx,ansy);
}
return 0;
}