#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cctype>
#include<vector>
#include<cassert>
#include<cmath>
using namespace std;


#define reg register
typedef long long ll;
typedef long double db;
#define rep(i,a,b) for(reg int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(reg int i=a,i##end=b;i>=i##end;--i)

#define Mod1(x) ((x>=P)&&(x-=P))
#define Mod2(x) ((x<0)&&(x+=P))
#define pb push_back
template <class T> inline void cmin(T &a,T b){ ((a>b)&&(a=b)); }
template <class T> inline void cmax(T &a,T b){ ((a<b)&&(a=b)); }

char IO;
template <class T=int> T rd(){
	T s=0; int f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}

namespace Geometry{
	const db eps=1e-7;
	const db inf=1.0/0.0,INF=1e18;
	const db Nan=0.0/0.0;
	int sign(db x){ return x<-eps?-1:x>eps; }
	int cmp(db x,db y){ return sign(x-y); }
	struct Point{
		db x,y;
		Point(){; }
		Point(db a,db b){ x=a,y=b; }
		db len(){ return sqrt(x*x+y*y); }
		Point Rot(db k){ return Point(x*sin(k)+y*cos(k),x*cos(k)-y*sin(k)); }
		Point Unit(){ db t=len(); return Point(x/t,y/t); }
		void Read(){ x=rd(),y=rd(); }
		//void Show(){ printf("(%.2lf,%.2lf)",x,y); }
	};
	typedef Point Vector;
	Vector operator + (Vector a,Vector b){ return Vector(a.x+b.x,a.y+b.y); }
	Vector operator - (Vector a,Vector b){ return Vector(a.x-b.x,a.y-b.y); }
	db operator * (Vector a,Vector b){ return a.x*b.x+a.y*b.y; }
	db operator ^ (Vector a,Vector b){ return a.x*b.y-a.y*b.x; }
	Vector operator * (Vector a,db x){ return Vector(a.x*x,a.y*x); }
	Vector operator * (db x,Vector a){ return Vector(a.x*x,a.y*x); }
	Vector operator / (Vector a,db x){ return Vector(a.x/x,a.y/x); }
	int operator == (Point a,Point b){ return cmp(a.x,b.x)==0 && cmp(a.y,b.y)==0; }
	db Ang(Vector a){ return atan2(a.y,a.x); }
	db Dis(Point x,Point y){ return (x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y); }
	db Ang(Vector x,Vector y){ return acos(x*y/(x.len()*y.len())); }

	int Get(Vector a){
		if(a.x>0 && a.y>=0) return 0;
		if(a.x<=0 && a.y>0) return 1;
		if(a.x<0 && a.y<=0) return 2;
		return 3;
	}
	int operator < (Vector a,Vector b) { 
		if(Get(a)==Get(b)) return sign(a^b)>0;
		return Get(a)<Get(b);
	}
	int operator <= (Vector a,Vector b){ return a==b || a<b; }
	db Calc_Area(vector <Point> V){
		int n=V.size(); db res=0;
		rep(i,0,V.size()-1) res+=V[i]^V[(i+1)%n];
		return fabs(res/2);
	}
	int On(Point x,Vector y,Point z){  // z On  Segment [x,x+y]
		z=z-x; 
		return y*z>=-eps && cmp(z^y,0)==0 && y.len()+eps>=z.len();
	}

	struct Line{
		db k,b;
		Line(){ ; } 
		Line(db x,db y){ k=x,b=y; }
		Line(Point x,Point y) {
			assert(cmp(x.x,y.x) || cmp(x.y,y.y));
			if(cmp(x.x,y.x)==0) k=inf,b=x.x;
			else {
				db t=(y.y-x.y)/(y.x-x.x);
				k=t,b=x.y-x.x*k;
			}
		}
		db operator [] (const db x){ return k==inf? Nan : k*x+b; }
	};
	int operator == (Line a,Line b){
		if(a.k==inf && b.k==inf) return cmp(a.b,b.b)==0;
		if(a.k==inf || b.k==inf) return 0;
		return cmp(a.b,b.b)==0 && cmp(a.k,b.k)==0;
	}
	db operator & (Line x,Line y){ 
		assert(fabs(x.k-y.k)>eps);
		if(y.k==inf) swap(x,y);
		if(x.k==inf) return x.b;
		return (x.b-y.b)/(y.k-x.k); 
	}
	db Dis(Line x,Point y){ 
		if(x.k==inf) return abs(x.b-y.x);
		return fabs((x[y.x]+y.y)/sqrt(x.k*x.k+1)); 
	}
	int Parallel(Line x,Line y){ 
		if(x.k==inf && y.k==inf) return 1;
		if(x.k==inf || y.k==inf) return 0;
		return cmp(x.k,y.k)==0;
	}

	/*struct Circle{
		Point x; db r;
		Circle(){ ; }
		Circle(Point _x,db _r){ x=_x,r=_r; }
		Circle(db _x,db _y,db _r){ x=Point(_x,_y),r=_r; }
	};
	int In(Circle a,Circle b){ return a.r*a.r>=Dis(a.x,b.x); }
	int Check_Cross(Circle a,Circle b) { return cmp((a.r+b.r)*(a.r+b.r),Dis(a.x,b.x)); }
	vector <Point> operator & (Circle a,Circle b){
		int t=Check_Cross(a,b);
		if(t<0) return {};
		;
		;
		return {};
	}*/
}
using namespace::Geometry;


const int N=110;


int n;




int main(){
	n=rd();
	rep(i,1,n){
		Point A,B,C,D;
		A.Read(),B.Read(),C.Read(),D.Read();
		Line X(A,B),Y(C,D);
		db x=X&Y;
		db y=(X.k!=inf)?X[x]:Y[x];
		printf("%.10Lf %.10Lf\n",x,y);
	}
}















Measured memory_bytes: 3220