#include<iostream>
#include<complex>
#include<vector>
#include<iomanip>

using namespace std;

typedef complex<double> P;

#define EPS 1e-9
#define shosu(x) fixed<<setprecision(x)

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L(){;}
};
struct C{
  P c;double r;
  C(const P &c,double r):c(c),r(r){}
};

namespace std{//演算子の定義
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real() && a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c) {//3点の関係性
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;                               // a--c--b on line
}

P projection(L l, P p){//pの直線l上の射影の点
  double t=dot(p-l[0],l[0]-l[1])/norm(l[0]-l[1]);
  return l[0]+t*(l[0]-l[1]);
}

P reflection(L l, P p){//点pの直線lに関して対称な点
  return p+2.0*(projection(l,p)-p);
}

bool isOrthogonal(L l, L m){//2直線の直交判定
  return fabs(dot(l[1]-l[0], m[1]-m[0])) < EPS;
}

bool isParallel(L l, L m){//2直線の平行判定
  return fabs(cross(l[1]-l[0],m[1]-m[0])) < EPS;
}

bool intersectLL(L l, L m){//2直線の交差判定
  return !isParallel(l,m);
}

bool intersectSS(const L &s, const L &t) { //2線分の交差判定(完全に交差してないとだめ)
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P crosspointSS(L a,L b){ //2線分の交点
double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
return b[0]+(b[1]-b[0])*t1/(t1+t2);
}

P inP(){
  double x,y;
  cin >> x >> y;
  P p(x,y);
  return p;
}

L inL(){
  P p1=inP();
  P p2=inP();
  L l(p1,p2);
  return l;
}

int main(){

  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    L l1,l2;
    l1=inL();
    l2=inL();

    P ans=crosspointSS(l1,l2);
    cout << shosu(10) << ans.real() << " " << ans.imag() << endl;
  }

}


### Prompt

Generate a Cpp solution to 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<complex>
#include<vector>
#include<iomanip>

using namespace std;

typedef complex<double> P;

#define EPS 1e-9
#define shosu(x) fixed<<setprecision(x)

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L(){;}
};
struct C{
  P c;double r;
  C(const P &c,double r):c(c),r(r){}
};

namespace std{//演算子の定義
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real() && a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c) {//3点の関係性
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;                               // a--c--b on line
}

P projection(L l, P p){//pの直線l上の射影の点
  double t=dot(p-l[0],l[0]-l[1])/norm(l[0]-l[1]);
  return l[0]+t*(l[0]-l[1]);
}

P reflection(L l, P p){//点pの直線lに関して対称な点
  return p+2.0*(projection(l,p)-p);
}

bool isOrthogonal(L l, L m){//2直線の直交判定
  return fabs(dot(l[1]-l[0], m[1]-m[0])) < EPS;
}

bool isParallel(L l, L m){//2直線の平行判定
  return fabs(cross(l[1]-l[0],m[1]-m[0])) < EPS;
}

bool intersectLL(L l, L m){//2直線の交差判定
  return !isParallel(l,m);
}

bool intersectSS(const L &s, const L &t) { //2線分の交差判定(完全に交差してないとだめ)
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P crosspointSS(L a,L b){ //2線分の交点
double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
return b[0]+(b[1]-b[0])*t1/(t1+t2);
}

P inP(){
  double x,y;
  cin >> x >> y;
  P p(x,y);
  return p;
}

L inL(){
  P p1=inP();
  P p2=inP();
  L l(p1,p2);
  return l;
}

int main(){

  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    L l1,l2;
    l1=inL();
    l2=inL();

    P ans=crosspointSS(l1,l2);
    cout << shosu(10) << ans.real() << " " << ans.imag() << endl;
  }

}


```