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:
// Written By NewbieChd
#include <iostream>
#include <iomanip>
#include <cmath>
// #define double long double
using namespace std;

const int maxN = 100003;
const double eps = 1e-8;
inline double absolute(double x) { return x >= 0 ? x : -x; }
inline double square(double x) { return x * x; }

struct Vector {
    double x, y;
    Vector() {}
    Vector(double x, double y) : x(x), y(y) {}
    friend Vector operator+(const Vector& a, const Vector& b) { return Vector(a.x + b.x, a.y + b.y); }
    friend Vector operator-(const Vector& a, const Vector& b) { return Vector(a.x - b.x, a.y - b.y); }
    friend Vector operator*(const Vector& a, const double& b) { return Vector(a.x * b, a.y * b); }
    friend Vector operator/(const Vector& a, const double& b) { return Vector(a.x / b, a.y / b); }
    inline double length() { return sqrt(square(x) + square(y)); }
    inline void read() { cin >> x >> y; }
    inline void write() { cout << fixed << setprecision(10) << x << ' ' << y << '\n'; }
};
inline double distance(Vector a, Vector b) { return sqrt(square(b.x - a.x) + square(b.y - a.y)); }
inline double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
inline double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }

inline Vector project(Vector a, Vector b, Vector c) {
    b = a - b;
    return b * (dot(b, c - a) / square(b.length())) + a;
}
inline Vector reflect(Vector a, Vector b, Vector c) {
    a = project(a, b, c);
    return a * 2 - c;
}

inline bool intersect(Vector a, Vector b, Vector c, Vector d) {
    if (max(min(a.x, b.x), min(c.x, d.x)) > min(max(a.x, b.x), max(c.x, d.x)) + eps || 
        max(min(a.y, b.y), min(c.y, d.y)) > min(max(a.y, b.y), max(c.y, d.y)) + eps || 
        cross(a - c, d - c) * cross(d - c, b - c) + eps < 0 || 
        cross(c - a, b - a) * cross(b - a, d - a) + eps < 0)
        return 0;
    return 1;
}

struct Line {
    double A, B, C;
    Line() {}
    Line(double A, double B, double C) : A(A), B(B), C(C) {}
};
inline Line getLine(Vector a, Vector b) { return Line(b.y - a.y, a.x - b.x, a.y * (b.x - a.x) - a.x * (b.y - a.y)); }
inline Vector crossPoint(Line a, Line b) {
    double tmp = a.A * b.B - a.B * b.A;
    return Vector((a.B * b.C - b.B * a.C) / tmp, (b.A * a.C - a.A * b.C) / tmp);
}

int main() {
    ios::sync_with_stdio(false);
    int Q;
    Vector a, b, c, d;
    for (cin >> Q; Q; --Q)
        a.read(), b.read(), c.read(), d.read(), crossPoint(getLine(a, b), getLine(c, d)).write();
    return 0;
}