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 <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

constexpr double EPS = 1e-10;
using Point = complex<double>;
using Line  = pair<Point, Point>;

double dot(Point p, Point q) { return (conj(p) * q).real(); }
double cross(Point p, Point q) { return (conj(p) * q).imag(); }

Point cross_point(Line a, Line b) {
    Point base = b.second - b.first;
    double area1 = abs(cross(base, a.first - b.first));
    double area2 = abs(cross(base, a.second - b.first));
    double t = area1 / (area1 + area2);
    return a.first + (a.second - a.first) * t;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int q; cin >> q;
    for(int i=0; i < q; ++i) {
        double a,b,c,d,e,f,g,h;
        cin>>a>>b>>c>>d>>e>>f>>g>>h;
        Line l1(Point(a,b), Point(c,d));
        Line l2(Point(e,f), Point(g,h));
        Point ret = cross_point(l1, l2);
        cout << ret.real() << " " << ret.imag() << '\n';
    }
    return 0;
}