#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

struct point{
	double x,y;
	point operator+(point Gep){
		return point{x+Gep.x,y+Gep.y};
	}
	point operator-(point Gep){
		return point{x-Gep.x,y-Gep.y};
	}
	point operator*(double Gex){
		return point{x*Gex,y*Gex};
	}
	point operator/(double Gex){
		if(!Gex) return point{0,0}; 
		return point{x/Gex,y/Gex};
	}
	bool operator==(point Gep){
		return fabs(x-Gep.x)<eps&&fabs(y-Gep.y)<eps;
	}
};

class Geom{
	private:
	vector<point> Ge;
	vector<pair<point,point> > Geseg,Geline;
	public:
	void line_push(point Gex,point Gey){
		Geline.push_back(make_pair(Gex,Gey));
	}
	void seg_push(point Gex,point Gey){
		Geseg.push_back(make_pair(Gex,Gey));
	}
	void point_push(point Gex){
		Ge.push_back(Gex);
	}
	point DIP(pair<point,point> Gex,pdd Gey){
		double Gea=Gey.first,Geb=Gey.second;
		point Ge1=Gex.first,Ge2=Gex.second;
		return (Ge1*Geb+Ge2*Gea)/(Gea+Geb);
	}
	point POI(pair<point,point>Gex,pair<point,point> Gey){
		pair<point,point> Ge1(PRO(Gex,Gey.first),PRO(Gex,Gey.second));
		pdd Ger(EXTLEN(Gey.first,Ge1.first),EXTLEN(Gey.second,Ge1.second));
		return DIP(Ge1,Ger);
	}
	double IP(point Gex,point Gey){
		return Gex.x*Gey.x+Gex.y*Gey.y;
	}
	double CP(point Gex,point Gey){
		return Gex.x*Gey.y-Gey.x*Gex.y;
	}
	double LEN(point Gex){
		return sqrt(Gex.x*Gex.x+Gex.y*Gex.y);
	}
	double EXTLEN(point Gex,point Gey){
		return LEN(Gex-Gey);
	}
	point PRO(pair<point,point> Gea,point Gex){
		point Ge1=Gex-Gea.second,Ge2=Gea.first-Gea.second;
		return Ge2*(IP(Ge1,Ge2)/(LEN(Ge2)*LEN(Ge2)))+Gea.second;
	}
	point REF(pair<point,point> Gea,point Gex){
		point Ge1=PRO(Gea,Gex);
		return Ge1*2-Gex;
	}
	int PJUD(point Gea,point Geb,point Gex){
		if(Gea==Geb||Gex==Geb) return 0;
		point Ge1=Gea-Gex,Ge2=Geb-Gex;
		double Getmp=CP(Ge1,Ge2);
		if(Getmp>0) return 1;
		if(Getmp<0) return 2;
		if(IP(Ge1,Ge2)<0) return 3;
		if(LEN(Ge1)<LEN(Ge2)) return 4;
		return 5;
	}
	int SJUD(pair<point,point> Gex,pair<point,point> Gey){
		point Getmp=POI(Gex,Gey);
		int Ge1=PJUD(Gex.first,Getmp,Gex.second),Ge2=PJUD(Gey.first,Getmp,Gey.second);
		if((!Ge1||Ge1==5)&&(!Ge2||Ge2==5)) return 1;
		return 0;
	}
	int LJUD(pair<point,point> Gex,pair<point,point> Gey){
		point Ge1=Gex.first-Gex.second,Ge2=Gey.first-Gey.second;
		if(!CP(Ge1,Ge2)) return 2;
		if(!IP(Ge1,Ge2)) return 1;
		return 0;
	}
	pair<point,point> line_open(int Gex){
		return Geline[Gex];
	}
	point point_open(int Gex){
		return Ge[Gex];
	}
	pair<point,point> seg_open(int Gex){
		return Geseg[Gex];
	}
};

int q;

int main(){
	cout<<shosu(11);
	cin>>q;
	for(int i=0;i<q;i++){
		Geom geo;
		for(int j=0;j<2;j++){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			geo.seg_push(point{a,b},point{c,d});
		}
		point tmp=geo.POI(geo.seg_open(0),geo.seg_open(1));
		cout<<tmp.x<<' '<<tmp.y<<endl;
	}
}

Measured memory_bytes: 1276