#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
bool eq(double a, double b) { return fabs(a - b) < EPS; }

struct point
{
	double x, y;
	point(double x = 0, double y = 0) :x(x), y(y) {};

	point operator + (point p) { return point(x + p.x, y + p.y); }
	point operator - (point p) { return point(x - p.x, y - p.y); }
	point operator * (double s) { return point(x * s, y * s); }
	point operator / (double s) { return point(x / s, y / s); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator < (const point &p) const
	{
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const point &p) const
	{
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

};
typedef vector<point> polygon;

double dot(point a, point b)
{
	return a.x*b.x + a.y*b.y;
}

double cross(point a, point b)
{
	return a.x*b.y - a.y*b.x;
}

int ccw(point a, point b, point c)
{
	b = b - a; c = c - a;
	if (cross(b, c) > EPS) return 1;//???????¨????????????????a,b,c??¨?????¶
	if (cross(b, c) < -EPS) return -1;//???????¨????????????????a,c,b??¨?????¶
	if (dot(b, c) < 0) return 2;//??´?????????c,a,b??????????????¶
	if (b.norm() < c.norm()) return -2;//??´?????????a,b,c??????????????¶
	return 0;//??´?????????a,c,b??????????????¶
}

struct line
{
	point a, b;
	line(double x1 = 0, double y1 = 0, double x2 = 0, double y2 = 0) :a(point(x1, y1)), b(point(x2, y2)) {};

	point univec() { return (b - a) / (b - a).norm(); }
};

point cross_point(line s1, line s2)
{
	point sv = s1.b - s1.a;
	point tv = s2.b - s2.a;
	return s1.a + sv*cross(tv, s2.a - s1.a) / cross(tv, sv);
}

line perbis(line l)
{
	double x = (l.a.x + l.b.x) / 2;
	double y = (l.a.y + l.b.y) / 2;
	point s(x, y);
	point v = l.b - s;
	point w(-v.y, v.x);
	point p = s + w;
	return line(s.x, s.y, p.x, p.y);
}

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		point p[4];
		REP(i, 4)
		{
			double x, y;
			cin >> x >> y;
			p[i] = point(x, y);
		}
		line s(p[0].x, p[0].y, p[1].x, p[1].y);
		line t(p[2].x, p[2].y, p[3].x, p[3].y);
		point ans = cross_point(s, t);
		cout << D10 << ans.x << " " << ans.y << endl;
	}


/*	while (n--)
	{
		double x[3], y[3];
		REP(i, 3) cin >> x[i] >> y[i];
		line a = perbis(line(x[0], y[0], x[1], y[1]));
		line b = perbis(line(x[0], y[0], x[2], y[2]));
		point ans = cross_point(a, b);
		cout << D10 << ans.x << " " << ans.y << " " << (ans - point(x[0], y[0])).abs() << endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 1296