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<bits/stdc++.h>

using namespace std;

#define eps (1e-10)
struct point{
    double x,y;
    point(){}
    point(double x,double y):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 k){return point(x*k,y*k);}
    point operator / (double k){return point(x/k,y/k);}

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

    bool operator < (const point &p){
        return x!=p.x?x<p.x:y<p.y;
    }
    bool operator == (const point &p){
        return fabs(x-p.x)<eps&&fabs(y-p.y)<eps;
    }
};
//内积
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;
}

point getcrosspoint(point a,point a1,point b,point b1)
{
    point base=b1-b;
    double d1=abs(cross(base,a-b));
    double  d2=abs(cross(base,a1-b));
    double t=d1/(d1+d2);
    point temp=(a1-a)*t;
    return a+temp;
}

int main()
{
    int q;
    cin>>q;
    point a,a1,b,b1;
    for(int i=0;i<q;i++){
        cin>>a.x>>a.y>>a1.x>>a1.y>>b.x>>b.y>>b1.x>>b1.y;
        point res=getcrosspoint(a,a1,b,b1);
        printf("%.10f %.10f\n",res.x,res.y);
    }
    return 0;
}