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>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8, pi = acos(-1.0);
bool eq(ld a, ld b){return (abs(b-a)<eps);}
ld dot(Point a, Point b){return real(conj(a)*b);}
ld cross(Point a, Point b){ return imag(conj(a)*b);}

class Line{
public:
  Point a,b;
};

bool Parallel(const Line& l1, const Line& l2){
  return eq(cross(l1.b-l1.a,l2.b-l2.a), 0);
}

bool Orthogonal(const Line& l1, const Line& l2){
  return eq(dot(l1.b-l1.a,l2.b-l2.a), 0);
}

void solve(Line s,Line t){
  Point sv=s.b-s.a,tv=t.b-t.a;
  Point result=s.a+sv*cross(tv,t.a-s.a)/cross(tv,sv);
  printf("%.10Lf %.10Lf\n",result.real(),result.imag());
}

int main(){
  int q;cin>>q;
  REP(i,q){
    ld real, imag;
    Line s1,s2;
    cin>>real>>imag;
    s1.a = Point(real,imag);
    cin>>real>>imag;
    s1.b = Point(real,imag);
    cin>>real>>imag;
    s2.a = Point(real,imag);
    cin>>real>>imag;
    s2.b = Point(real,imag);
    solve(s1,s2);
  }
}