Problem: For given two segments s1 and s2, print the coordinate of the cross point of them.

s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3.

Constraints

* 1 ≤ q ≤ 1000
* -10000 ≤ xpi, ypi ≤ 10000
* p0 ≠ p1 and p2 ≠ p3.
* The given segments have a cross point and are not in parallel.

Input

The entire input looks like:


q (the number of queries)
1st query
2nd query
...
qth query


Each query consists of integer coordinates of end points of s1 and s2 in the following format:


xp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3


Output

For each query, print the coordinate of the cross point. The output values should be in a decimal fraction with an error less than 0.00000001.

Example

Input

3
0 0 2 0 1 1 1 -1
0 0 1 1 0 1 1 0
0 0 1 1 1 0 0 1


Output

1.0000000000 0.0000000000
0.5000000000 0.5000000000
0.5000000000 0.5000000000

Solution (in CPP):

Solution:

//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second

inline int in(){int X, Y; Y = scanf("%d", &X); return X; }

const int N = -1;
const ld EPS = 1e-12;

bool eq(ld a, ld b){
	return abs(a-b) < EPS;
}

struct PT{
	ld X, Y;
	PT (ld X = 0, ld Y = 0) : X(X), Y(Y) {}
	PT operator + (PT ro) const{
		return PT(X+ro.X, Y+ro.Y);
	}
	PT operator - (PT ro) const{
		return PT(X-ro.X, Y-ro.Y);
	}
	PT operator * (ld co) const{
		return PT(X*co, Y*co);
	}
	PT operator / (ld co) const{
		return PT(X/co, Y/co);
	}
	ld operator * (PT ro) const{
		return X*ro.X + Y*ro.Y;
	}
	ld operator ^ (PT ro) const{
		return X*ro.Y - Y*ro.X;
	}
	void operator -= (PT ro){
		(*this) = (*this) - ro;
	}
};

istream& operator>> (istream &is, PT &p){
	ld val;
	is >> val;
	p.X = val;
	is >> val;
	p.Y = val;
	return is;
}

PT operator * (ld co, PT p){
	return p*co;
}

ld len(PT a){
	return sqrt(a*a);
}

PT unit(PT a){
	return a/len(a);
}

PT clrot(PT a){
	return PT(-a.Y, a.X);
}

PT proj(PT a, PT b, PT c){
	b = b-a, c = c-a;
	return a + (b*c)/(b*b)*b;
}

PT reflect(PT a, PT b, PT c){
	PT d = c;
	b = b-a, c = c-a;
	return d + (c^b)/len(b)*clrot(unit(b))*2;
}

int sgn(PT a, PT b, PT c){
	ld cr = (b-a)^(c-a);
	return cr > EPS ? 1 : (cr + EPS < 0 ? -1 : 0);
}

bool intersect(PT a, PT b, PT c, PT d){
	int as = sgn(c, d, a),
		bs = sgn(c, d, b),
		cs = sgn(a, b, c),
		ds = sgn(a, b, d);
	if (as && as == bs || cs && cs == ds)
		return false;
	else if (as || bs || cs || ds)
		return true;
	for (int j = 0; j < 2; j++){
		ld mX = min(a.X, b.X),
		   MX = max(a.X, b.X),
		   mY = min(a.Y, b.Y),
		   MY = max(a.Y, b.Y);
		for (int k = 0; k < 2; k++){
			if (c.X + EPS > mX && c.X < MX + EPS && c.Y + EPS > mY && c.Y < MY + EPS)
				return true;
			swap(c, d);
		}
		swap(a, c);
		swap(b, d);
	}
	return false;
}

PT intersection(PT a, PT b, PT c, PT d){
	ld c1 = (b-a)^(c-a), c2 = (b-a)^(d-a);
	return (c1*d - c2*c)/(c1 - c2);
}

int main(){
	cout << setprecision(10) << fixed;
	for (int i = in(); i; i--){
		PT a, b, c, d;
		cin >> a >> b >> c >> d;
		PT o = intersection(a, b, c, d);
		cout << o.X << ' ' << o.Y << '\n';
	}
	return 0;
}