#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(double k){return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{
    return fabs(x-p.x)<eps && fabs(y-p.y)<eps;
  }
  double dot(Point p){return x*p.x+y*p.y;}
  double det(Point p){return x*p.y-y*p.x;}
};
struct Line{
  Point p1,p2;
  Line(){}
  Line(Point p1, Point p2):p1(p1),p2(p2){}
};
int ccw(Point a,Point b,Point c){
  Point t1=b-a,t2=c-a;
  if(t1.det(t2)> eps) return 1;//counter clockwise
  if(t1.det(t2)< -eps) return -1;//clockwise
  if(t1.dot(t2)< -eps) return 2;//c-a-b online
  if(t1.norm()<t2.norm()) return -2;//a-b-c online
  return 0;//a-c-b online
}
bool intersectSS(Point a,Point b,Point c,Point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}
bool intersectSS(Line l1,Line l2){
  return intersectSS(l1.p1,l1.p2,l2.p1,l2.p2);
}
bool isOrthogonal(Point a,Point b){
  return fabs(a.dot(b))<eps;
}
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}
bool isParallel(Point a,Point b){
  return fabs(a.det(b))<eps;
}
bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}
Point CrossPoint(Line l1,Line l2){
    double a=(l1.p2-l1.p1).det(l2.p2-l2.p1);
    double b=(l1.p2-l1.p1).det(l1.p2-l2.p1);
    if(fabs(a)<eps&&fabs(b)<eps) return l2.p1;
    return l2.p1+(l2.p2-l2.p1)*(b/a);
}
int main(){
    int n;
    double xp0,yp0,xp1,yp1,xp2,yp2,xp3,yp3;
    cin>>n;
    while(n--){
        cin>>xp0>>yp0>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3;
        Point p0(xp0,yp0),p1(xp1,yp1),p2(xp2,yp2),p3(xp3,yp3);
        Point ans=CrossPoint(Line(p0,p1),Line(p2,p3));
        cout<<fixed<<setprecision(10)<<ans.x<<" "<<ans.y<<endl;
    }
    return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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 <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(double k){return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{
    return fabs(x-p.x)<eps && fabs(y-p.y)<eps;
  }
  double dot(Point p){return x*p.x+y*p.y;}
  double det(Point p){return x*p.y-y*p.x;}
};
struct Line{
  Point p1,p2;
  Line(){}
  Line(Point p1, Point p2):p1(p1),p2(p2){}
};
int ccw(Point a,Point b,Point c){
  Point t1=b-a,t2=c-a;
  if(t1.det(t2)> eps) return 1;//counter clockwise
  if(t1.det(t2)< -eps) return -1;//clockwise
  if(t1.dot(t2)< -eps) return 2;//c-a-b online
  if(t1.norm()<t2.norm()) return -2;//a-b-c online
  return 0;//a-c-b online
}
bool intersectSS(Point a,Point b,Point c,Point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}
bool intersectSS(Line l1,Line l2){
  return intersectSS(l1.p1,l1.p2,l2.p1,l2.p2);
}
bool isOrthogonal(Point a,Point b){
  return fabs(a.dot(b))<eps;
}
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}
bool isParallel(Point a,Point b){
  return fabs(a.det(b))<eps;
}
bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}
Point CrossPoint(Line l1,Line l2){
    double a=(l1.p2-l1.p1).det(l2.p2-l2.p1);
    double b=(l1.p2-l1.p1).det(l1.p2-l2.p1);
    if(fabs(a)<eps&&fabs(b)<eps) return l2.p1;
    return l2.p1+(l2.p2-l2.p1)*(b/a);
}
int main(){
    int n;
    double xp0,yp0,xp1,yp1,xp2,yp2,xp3,yp3;
    cin>>n;
    while(n--){
        cin>>xp0>>yp0>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3;
        Point p0(xp0,yp0),p1(xp1,yp1),p2(xp2,yp2),p3(xp3,yp3);
        Point ans=CrossPoint(Line(p0,p1),Line(p2,p3));
        cout<<fixed<<setprecision(10)<<ans.x<<" "<<ans.y<<endl;
    }
    return 0;
}

```