#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8  
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

typedef double coordinate_t;

struct coordinate {
  coordinate_t x, y;
  bool operator<(const coordinate & another) const {
    return x != another.x ? x < another.x : y < another.y;
  }
};

struct line {
  coordinate_t a;
  coordinate_t b;
  coordinate_t c;
};

// the intersections of 2 lines
coordinate cross_of_2_lines(line k, line l) {
  coordinate_t dn = l.a * k.b - k.a * l.b;
  if (dn == 0) return{ NAN, NAN };
  else {
    coordinate_t x = (l.b * k.c - k.b * l.c) / dn;
    coordinate_t y = (k.a * l.c - l.a * k.c) / dn;
    return{ x,y };
  }
}


// the intersections of n lines
vector<coordinate> crosses_of_lines(vector<line> lines) {
  int n = lines.size();
  set<coordinate> st;
  Loop(i, n) {
    Loop(j, i) {
      coordinate p = cross_of_2_lines(lines[i], lines[j]);
      if (p.x != NAN && p.y != NAN) st.insert(p);
    }
  }
  vector<coordinate> ret;
  for (auto itr = st.begin(); itr != st.end(); itr++) {
    ret.push_back(*itr);
  }
  return ret;
}


// the line through 2 coordinates
line line_through_2_coordinates(coordinate p, coordinate q) {
  if (p.x == q.x && p.y == q.y) return{ NAN, NAN, NAN };
  else {
    if (p.x == q.x) {
      return { 1, 0, -p.x };
    }
    else {
      return { (q.y - p.y), (p.x - q.x), q.x * p.y - p.x * q.y };
    }
  }
}



int main() {
  int q; cin >> q;
  cout << setprecision(18);
  Loop(i, q) {
    coordinate p, q;
    line s, t;
    cin >> p.x >> p.y >> q.x >> q.y;
    s = line_through_2_coordinates(p, q);
    cin >> p.x >> p.y >> q.x >> q.y;
    t = line_through_2_coordinates(p, q);
    coordinate r = cross_of_2_lines(s, t);
    cout << r.x << " " << r.y << endl;
  }
}

### Prompt

In cpp, your task is to solve the following 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

### Response

```cpp
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8  
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

typedef double coordinate_t;

struct coordinate {
  coordinate_t x, y;
  bool operator<(const coordinate & another) const {
    return x != another.x ? x < another.x : y < another.y;
  }
};

struct line {
  coordinate_t a;
  coordinate_t b;
  coordinate_t c;
};

// the intersections of 2 lines
coordinate cross_of_2_lines(line k, line l) {
  coordinate_t dn = l.a * k.b - k.a * l.b;
  if (dn == 0) return{ NAN, NAN };
  else {
    coordinate_t x = (l.b * k.c - k.b * l.c) / dn;
    coordinate_t y = (k.a * l.c - l.a * k.c) / dn;
    return{ x,y };
  }
}


// the intersections of n lines
vector<coordinate> crosses_of_lines(vector<line> lines) {
  int n = lines.size();
  set<coordinate> st;
  Loop(i, n) {
    Loop(j, i) {
      coordinate p = cross_of_2_lines(lines[i], lines[j]);
      if (p.x != NAN && p.y != NAN) st.insert(p);
    }
  }
  vector<coordinate> ret;
  for (auto itr = st.begin(); itr != st.end(); itr++) {
    ret.push_back(*itr);
  }
  return ret;
}


// the line through 2 coordinates
line line_through_2_coordinates(coordinate p, coordinate q) {
  if (p.x == q.x && p.y == q.y) return{ NAN, NAN, NAN };
  else {
    if (p.x == q.x) {
      return { 1, 0, -p.x };
    }
    else {
      return { (q.y - p.y), (p.x - q.x), q.x * p.y - p.x * q.y };
    }
  }
}



int main() {
  int q; cin >> q;
  cout << setprecision(18);
  Loop(i, q) {
    coordinate p, q;
    line s, t;
    cin >> p.x >> p.y >> q.x >> q.y;
    s = line_through_2_coordinates(p, q);
    cin >> p.x >> p.y >> q.x >> q.y;
    t = line_through_2_coordinates(p, q);
    coordinate r = cross_of_2_lines(s, t);
    cout << r.x << " " << r.y << endl;
  }
}

```