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:
/* Header {{{ */
#include <bits/stdc++.h>
using namespace std;

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

#ifdef LOCAL_LOGGER
#define logger(...) fprintf(stderr, __VA_ARGS__)
#define abortif(v, ...) if (v) {logger("Error in Line %d, Function '%s()'.\nInfo: ", __LINE__, __FUNCTION__); logger(__VA_ARGS__); exit(0);}
#else
#define logger(...);
#define abortif(v, ...);
#endif
/* }}} */

const let EPS = 1e-8;

struct Point {
  let x, y;
  friend Point operator + (Point a, Point b) {
    return (Point) {a.x + b.x, a.y + b.y};
  }
  friend Point operator - (Point a, Point b) {
    return (Point) {a.x - b.x, a.y - b.y};
  }
  Point operator ~ () {
    return (Point) {x, -y};
  }
  Point operator * (let k) { return (Point) {x * k, y * k}; }

  let dist() {
    return sqrt(x * x + y * y);
  }

  Point Rotate(let sink, let cosk) {
    return (Point) {
      x * cosk - y * sink, x * sink + y * cosk
    };
  }

  Point Rotate(Point k) {
    let z = k.dist();
    return Rotate(k.y / z, k.x / z);
  }

  void EchoWith(char c) {
    printf("%.8Lf %.8Lf", x, y);
    putchar(c);
  }
};

typedef Point Vec;

struct Segment {
  Point s, e;
  Vec v;
  Segment() {}
  Segment(Point a, Point b) {
    s = a, e = b, v = b - a;
  }
  Segment(Point a, Point b, Vec c) {
    s = a, e = b, v = c;
  }

  Segment operator - (Vec k) {
    return (Segment) {
      s - k, e - k, v
    };
  }

  Segment Rotate(let sink, let cosk) {
    return (Segment) {
      s.Rotate(sink, cosk), e.Rotate(sink, cosk), v.Rotate(sink, cosk)
    };
  }

  Segment Rotate(Vec k) {
    let z = k.dist();
    return Rotate(k.y / z, k.x / z);
  }

  friend Point CrossPoint(Segment a, Segment b) {
    Segment c = (b - a.s).Rotate(~a.v);
    return (c.e - c.v * (c.e.y / c.v.y)).Rotate(a.v) + a.s;
  }
};

Point ReadPoint() {
  Point t;
  scanf("%Lf%Lf", &t.x, &t.y);
  return t;
}

int main() {
// #ifndef ONLINE_JUDGE
//   freopen("CGL_2_C.in", "r", stdin);
//   freopen("CGL_2_C.out", "w", stdout);
// #endif
// #ifdef LOCAL_LOGGER
//   freopen("CGL_2_C.log", "w", stderr);
// #endif
  int q = read();
  while (q--) {
    Point p0 = ReadPoint(), p1 = ReadPoint(), p2 = ReadPoint(), p3 = ReadPoint();
    Segment s1 = Segment(p0, p1), s2 = Segment(p2, p3);
    CrossPoint(s1, s2).EchoWith('\n');
  }
  return 0;
}

/* ==== Makefile ==== {{{
CompileAndRun:
	make Compile
	make Run

Compile:
	g++ -o CGL_2_C CGL_2_C.cpp -g -Wall -DLOCAL_LOGGER

CompileUF:
	g++ -o CGL_2_C CGL_2_C.cpp -g -Wall -DLOCAL_LOGGER -fsanitize=undefined

Run:
	./CGL_2_C < CGL_2_C.in > CGL_2_C.out
==================
}}} */