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:
//
// Created by 肖龙 on 2020/3/18.
//

#include<iostream>
#include <cmath>
#include <iomanip>

using namespace std;

typedef struct point{
    double x,y;
    void input(){
        cin>>x>>y;
    }
}Point,Vector;

typedef struct line{
    Point x;
    Vector k;
}Line;

typedef struct sugment{
    Point x,y;
    void input(){
        x.input();
        y.input();
    }
}Sug;

//点积
double dot(Vector x,Vector y){
    return x.x*y.x+x.y*y.y;
}

//叉积
double cross(Vector x,Vector y){
    return x.x*y.y-x.y*y.x;
}

double getlen(Vector x){
    return sqrt(dot(x,x));
}

Vector getV(Point x,Point y){
    Vector v;
    v.x=y.x-x.x;
    v.y=y.y-x.y;
    return v;
}
//点在直线的投影
Point Projection(Line x,Point y){
    Point answ;
    answ = x.x;

    double len = dot(x.k,getV(x.x,y));
    len/=sqrt(x.k.x*x.k.x+x.k.y*x.k.y);
    Vector temp  = x.k;
    temp.x /=sqrt(x.k.x*x.k.x+x.k.y*x.k.y);
    temp.y/=sqrt(x.k.x*x.k.x+x.k.y*x.k.y);
    answ.x+=temp.x*len;
    answ.y+=temp.y*len;
    return answ;
}
//点与直线的对称点
Point Reflection(Line x,Point y){
    Point half = Projection(x,y);
    Point answ;
    answ.x=y.x+2*(half.x-y.x);
    answ.y=y.y+2*(half.y-y.y);
    return answ;
}

Point getCP(Sug x,Sug y){
    Point a,b,c,d,z;
    a=x.x;
    b=x.y;
    c=y.x;
    d=y.y;
    z.x=((b.x - a.x) * (c.x - d.x) * (c.y - a.y) -
         c.x * (b.x - a.x) * (c.y - d.y) + a.x * (b.y - a.y) * (c.x - d.x)) /
        ((b.y - a.y) * (c.x - d.x) - (b.x - a.x) * (c.y - d.y));
    z.y=((b.y - a.y) * (c.y - d.y) * (c.x - a.x) -
            c.y * (b.y - a.y) * (c.x - d.x) + a.y * (b.x - a.x) * (c.y - d.y))
        / ((b.x - a.x) * (c.y - d.y) - (b.y - a.y) * (c.x - d.x));
    return z;
}

int main(){
    int t;
    cin>>t;
    Sug x,y;
    Point z;
    while(t--){
        x.input();
        y.input();
        z=getCP(x,y);
        cout<<setprecision(10)<<setiosflags(ios::fixed)<<z.x<<" "<<z.y<<endl;
    }
    return 0;
}