#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
#define enter putchar('\n')

typedef long long ll;
typedef double DB;

const DB eps = 1e-12;

int sgn(DB x) { return fabs(x) < eps ? 0 : (x > 0 ? 1 : -1); }

struct Point {
	DB x, y;
	Point(DB x = 0, DB y = 0) : x(x), y(y) {}
	Point operator + (Point a) { return Point(x + a.x, y + a.y); }
	Point operator - (Point a) { return Point(x - a.x, y - a.y); }
	Point operator - () { return Point(-x, -y); }
	friend Point operator * (DB k, Point a) { return Point(k * a.x, k * a.y); }
	DB operator % (Point a) { return x * a.x + y * a.y; }
	DB operator / (Point a) { return x * a.y - y * a.x; }
	operator DB() { return sqrt(x*x + y*y); }
};

Point gp() { Point a; scanf("%lf%lf", &a.x, &a.y); return a; }
void wp(Point a) { printf("%.10lf %.10lf ", a.x, a.y); }

struct Poly {
	std::vector<Point> a;
	Poly(int n = 0) { a.resize(n); rep0(i, n) a[i] = gp(); }
	Point &operator [] (int i) { int n = a.size(); return a[i >= n ? i-n : i]; }
};

Point Proj(Point P, Point P1, Point P2) { // Projection
	Point v = P2-P1; DB t = (P-P1)%v / (v%v);
	return P1 + t*v;
}

int Direct(Point P, Point P1, Point P2) { return sgn((P1-P)/(P2-P)); }

bool IsSegInter(Point P1, Point P2, Point Q1, Point Q2) {
	if (min(P1.x, P2.x) <= max(Q1.x, Q2.x) && max(P1.x, P2.x) >= min(Q1.x, Q2.x) && min(P1.y, P2.y) <= max(Q1.y, Q2.y) && max(P1.y, P2.y) >= min(Q1.y, Q2.y))
		if (Direct(P1, P2, Q1) * Direct(P1, P2, Q2) <= 0 && Direct(Q1, Q2, P1) * Direct(Q1, Q2, P2) <= 0) return 1;
	return 0;
}

Point GetSegInter(Point P1, Point P2, Point Q1, Point Q2) {
	Point v = P2-P1, w = Q2-Q1; DB t = (Q1-P1)/w / (v/w);
	return P1 + t*v;
}

int q;

int main() {
	scanf("%d", &q);
	while (q--) {
		Point P1 = gp(), P2 = gp(), Q1 = gp(), Q2 = gp();
		wp(GetSegInter(P1, P2, Q1, Q2)); enter;
		//printf("%d\n", IsInter(P1, P2, Q1, Q2));
		//wp(Proj(P, P1, P2)); enter;
	}
	return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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

### Response

```cpp
#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
#define enter putchar('\n')

typedef long long ll;
typedef double DB;

const DB eps = 1e-12;

int sgn(DB x) { return fabs(x) < eps ? 0 : (x > 0 ? 1 : -1); }

struct Point {
	DB x, y;
	Point(DB x = 0, DB y = 0) : x(x), y(y) {}
	Point operator + (Point a) { return Point(x + a.x, y + a.y); }
	Point operator - (Point a) { return Point(x - a.x, y - a.y); }
	Point operator - () { return Point(-x, -y); }
	friend Point operator * (DB k, Point a) { return Point(k * a.x, k * a.y); }
	DB operator % (Point a) { return x * a.x + y * a.y; }
	DB operator / (Point a) { return x * a.y - y * a.x; }
	operator DB() { return sqrt(x*x + y*y); }
};

Point gp() { Point a; scanf("%lf%lf", &a.x, &a.y); return a; }
void wp(Point a) { printf("%.10lf %.10lf ", a.x, a.y); }

struct Poly {
	std::vector<Point> a;
	Poly(int n = 0) { a.resize(n); rep0(i, n) a[i] = gp(); }
	Point &operator [] (int i) { int n = a.size(); return a[i >= n ? i-n : i]; }
};

Point Proj(Point P, Point P1, Point P2) { // Projection
	Point v = P2-P1; DB t = (P-P1)%v / (v%v);
	return P1 + t*v;
}

int Direct(Point P, Point P1, Point P2) { return sgn((P1-P)/(P2-P)); }

bool IsSegInter(Point P1, Point P2, Point Q1, Point Q2) {
	if (min(P1.x, P2.x) <= max(Q1.x, Q2.x) && max(P1.x, P2.x) >= min(Q1.x, Q2.x) && min(P1.y, P2.y) <= max(Q1.y, Q2.y) && max(P1.y, P2.y) >= min(Q1.y, Q2.y))
		if (Direct(P1, P2, Q1) * Direct(P1, P2, Q2) <= 0 && Direct(Q1, Q2, P1) * Direct(Q1, Q2, P2) <= 0) return 1;
	return 0;
}

Point GetSegInter(Point P1, Point P2, Point Q1, Point Q2) {
	Point v = P2-P1, w = Q2-Q1; DB t = (Q1-P1)/w / (v/w);
	return P1 + t*v;
}

int q;

int main() {
	scanf("%d", &q);
	while (q--) {
		Point P1 = gp(), P2 = gp(), Q1 = gp(), Q2 = gp();
		wp(GetSegInter(P1, P2, Q1, Q2)); enter;
		//printf("%d\n", IsInter(P1, P2, Q1, Q2));
		//wp(Proj(P, P1, P2)); enter;
	}
	return 0;
}

```