#include<bits/stdc++.h>
using namespace std;
#define eps 0
typedef struct{
	double x,y;
	
}point;

typedef struct{
point a,b;
}line;

line make_line(point a,point b){
	line res; res.a=a; res.b=b;
	return res;
}
point make(double x,double y){
	point res;
	res.x=x;
	res.y=y;
	return res;
}
//a-b
point vec(point a,point b){
	point res;
	res.x=a.x-b.x;
	res.y=a.y-b.y;
	return res;
}

// a・b
double dot(point a,point b){
	return a.x*b.x+a.y*b.y;
}
//|a|
double  norm(point a){
return sqrt(dot(a,a));
}
//|a|^2
double absolute(point a){
return dot(a,a);
}
//a×ｂ　外積z成分
double cross(point a,point b){
return a.x*b.y-a.y*b.x;
}
//a=x1+iy1,b=x2+iy2 a*b
point imaseki(point a,point b){
point res;
res.x=a.x*b.x-a.y*b.y;
res.y=a.x*b.y+a.y*b.x;
return res;
}
//vec * a
point product(point v,double a){
	point res; res.x=v.x*a; res.y=v.y*a;
	return res;
}

//共役
point conjugate(point a){
point res;
res.x=a.x;
res.y=-a.y;
return res;
}


int ccw(point p0,point p1,point p2){
point a=vec(p1,p0);
point b=vec(p2,p0);
	if(cross(a,b)>eps){
	return 1;//counter_clockwise
	}else if(cross(a,b)<eps){
	return -1;//clockwise
	}else if(dot(a,b)<-eps){
	return 2;//online_back
	}else if(absolute(a)<absolute(b)){
	return -2;//online_front
	}else{
	return 0;//on_segment
	}

}
//交差判定　s1-s2 s3-s4
bool intersect(point s1,point s2,point s3,point s4){
 if(ccw(s1,s2,s3)*ccw(s1,s2,s4)<=0 && ccw(s3,s4,s1)*ccw(s3,s4,s2)<=0)
        return true;
    return false;
}

//交点
point crosspoint(line l1,line l2){
	point veca=vec(l1.b,l1.a);
	point vecb=vec(l2.b,l2.a);
	double d= cross(veca,vecb);
	double e= cross(vecb,vec(l2.b,l1.a));
	return vec(l1.a,product(veca,e/d));

}
int main(){
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
	double x,y;
	point p0,p1,p2,p3;
	cin>>x>>y;
	p0=make(x,y);
	cin>>x>>y;
	p1=make(x,y);
	cin>>x>>y;
	p2=make(x,y);
	cin>>x>>y;
	p3=make(x,y);
	line l1,l2;
	l1=make_line(p0,p1);
	l2=make_line(p2,p3);
	point ans= crosspoint(l1,l2);
//	cout<<ans.x<<' '<<ans.y<<endl;
	printf("%0.10lf %0.10lf\n",ans.x,ans.y);

	}
return 0;
}


### Prompt

Please formulate a cpp solution to the following 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

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define eps 0
typedef struct{
	double x,y;
	
}point;

typedef struct{
point a,b;
}line;

line make_line(point a,point b){
	line res; res.a=a; res.b=b;
	return res;
}
point make(double x,double y){
	point res;
	res.x=x;
	res.y=y;
	return res;
}
//a-b
point vec(point a,point b){
	point res;
	res.x=a.x-b.x;
	res.y=a.y-b.y;
	return res;
}

// a・b
double dot(point a,point b){
	return a.x*b.x+a.y*b.y;
}
//|a|
double  norm(point a){
return sqrt(dot(a,a));
}
//|a|^2
double absolute(point a){
return dot(a,a);
}
//a×ｂ　外積z成分
double cross(point a,point b){
return a.x*b.y-a.y*b.x;
}
//a=x1+iy1,b=x2+iy2 a*b
point imaseki(point a,point b){
point res;
res.x=a.x*b.x-a.y*b.y;
res.y=a.x*b.y+a.y*b.x;
return res;
}
//vec * a
point product(point v,double a){
	point res; res.x=v.x*a; res.y=v.y*a;
	return res;
}

//共役
point conjugate(point a){
point res;
res.x=a.x;
res.y=-a.y;
return res;
}


int ccw(point p0,point p1,point p2){
point a=vec(p1,p0);
point b=vec(p2,p0);
	if(cross(a,b)>eps){
	return 1;//counter_clockwise
	}else if(cross(a,b)<eps){
	return -1;//clockwise
	}else if(dot(a,b)<-eps){
	return 2;//online_back
	}else if(absolute(a)<absolute(b)){
	return -2;//online_front
	}else{
	return 0;//on_segment
	}

}
//交差判定　s1-s2 s3-s4
bool intersect(point s1,point s2,point s3,point s4){
 if(ccw(s1,s2,s3)*ccw(s1,s2,s4)<=0 && ccw(s3,s4,s1)*ccw(s3,s4,s2)<=0)
        return true;
    return false;
}

//交点
point crosspoint(line l1,line l2){
	point veca=vec(l1.b,l1.a);
	point vecb=vec(l2.b,l2.a);
	double d= cross(veca,vecb);
	double e= cross(vecb,vec(l2.b,l1.a));
	return vec(l1.a,product(veca,e/d));

}
int main(){
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
	double x,y;
	point p0,p1,p2,p3;
	cin>>x>>y;
	p0=make(x,y);
	cin>>x>>y;
	p1=make(x,y);
	cin>>x>>y;
	p2=make(x,y);
	cin>>x>>y;
	p3=make(x,y);
	line l1,l2;
	l1=make_line(p0,p1);
	l2=make_line(p2,p3);
	point ans= crosspoint(l1,l2);
//	cout<<ans.x<<' '<<ans.y<<endl;
	printf("%0.10lf %0.10lf\n",ans.x,ans.y);

	}
return 0;
}


```