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:
#include <iostream>
#include <iomanip>

class Point{
public:
	double x, y;
	Point(){
		x = y = 0;
	}
	Point(double _x, double _y){
		x = _x;
		y = _y;
	}
};

class Segment{
public:
	Point begin, end;
	Segment(){
		begin = Point();
		end = Point();
	}
	Segment(Point _begin, Point _end){
		begin = _begin;
		end = _end;
	}
};

int SegmentsIntersectionPoint(Segment &a, Segment &b, Point &out){
	double d = (a.end.x - a.begin.x) * (b.end.y - b.begin.y) - (a.end.y - a.begin.y) * (b.end.x - b.begin.x);
	double s = (b.end.y - b.begin.y) * (b.begin.x - a.begin.x) - (b.end.x - b.begin.x) * (b.begin.y - a.begin.y);
	double t = (a.end.y - a.begin.y) * (b.begin.x - a.begin.x) - (a.end.x - a.begin.x) * (b.begin.y - a.begin.y);
	
	if(d == 0){
		//????????§???????????????
		return 1;
	}
	
	out.x = a.begin.x + s * (a.end.x - a.begin.x) / d;
	out.y = a.begin.y + s * (a.end.y - a.begin.y) / d;
	
	return 0;
}

int main(){
	int n;
	int xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3;
	Point insc;
	Segment a, b;
	
	std::cin >> n;
	for(int i=0;i<n;++i){
		std::cin >> xp0 >> yp0 >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3;
		a = Segment(Point(xp0, yp0), Point(xp1, yp1));
		b = Segment(Point(xp2, yp2), Point(xp3, yp3));
		
		SegmentsIntersectionPoint(a, b, insc);
		
		std::cout << std::setprecision(15) << insc.x << " " << insc.y << std::endl;
	}
	
	return 0;
}