#include <cstdio>
#include <cmath>
using namespace std;
const double eps = 1e-8;
struct Point {
double x, y;
};
struct Vector {
double x, y;
};
double Distance(Point A, Point B) {
double dx = A.x - B.x;
double dy = A.y - B.y;
return sqrt(dx * dx + dy * dy);
}
double Scalar_Product(Vector a, Vector b) {
return a.x * b.x + a.y * b.y;
}
double Cross_Product(Vector a, Vector b) {
return a.x * b.y - a.y * b.x;
}
inline bool Collinear(Point A, Point O, Point B) {
Vector a = {O.x - A.x, O.y - A.y}, b = {B.x - O.x, B.y - O.y};
return fabs(Cross_Product(a, b)) < eps && Scalar_Product(a, b) > -eps;
}
inline double Triangle_Area(Point A, Point B, Point C) {
double a = Distance(B, C), b = Distance(A, C), c = Distance(A, B);
double p = (a + b + c) / 2;
return sqrt(p * (p - a) * (p - b) * (p - c));
}
Point Middle_Point(Point A, Point B) {
return {(A.x + B.x) / 2, (A.y + B.y) / 2};
}
Point Search(Point l, Point r, Point P, Point A, Point B, double Extend_Right) {
if (fabs(l.x - r.x) < eps && fabs(l.y - r.y) < eps)return Middle_Point(l, r);
Point mid = Middle_Point(l, r);
if (Triangle_Area(A, P, mid) < Triangle_Area(B, P, mid) + Extend_Right)
return Search(mid, r, P, A, B, Extend_Right);
else if (Triangle_Area(A, P, mid) > Triangle_Area(B, P, mid) + Extend_Right)
return Search(l, mid, P, A, B, Extend_Right);
else return mid;
}
inline Point Solve(Point P, Point A, Point B) {
return Search(A, B, P, A, B, 0);
}
inline Point Solve(Point P, Point A, Point O, Point B) {
if (Triangle_Area(P, A, O) > Triangle_Area(P, B, O))
return Search(A, O, P, A, O, Triangle_Area(P, B, O));
else if (Triangle_Area(P, A, O) < Triangle_Area(P, B, O))
return Search(B, O, P, B, O, Triangle_Area(P, A, O));
else return O;
}
signed main() {
// freopen("in", "r", stdin), freopen("out", "w", stdout);
int Ts;
scanf("%d", &Ts);
while (Ts--) {
Point A{}, B{}, C{}, P{};
scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y, &P.x, &P.y);
if (P.x == A.x && P.y == A.y) {
Point ans = Solve(P, B, C);
printf("%lf %lf\n", ans.x, ans.y);
} else if (P.x == B.x && P.y == B.y) {
Point ans = Solve(P, A, C);
printf("%lf %lf\n", ans.x, ans.y);
} else if (P.x == C.x && P.x == C.y) {
Point ans = Solve(P, A, B);
printf("%lf %lf\n", ans.x, ans.y);
} else if (Collinear(A, P, B)) {
Point ans = Solve(P, A, C, B);
printf("%lf %lf\n", ans.x, ans.y);
} else if (Collinear(A, P, C)) {
Point ans = Solve(P, A, B, C);
printf("%lf %lf\n", ans.x, ans.y);
} else if (Collinear(B, P, C)) {
Point ans = Solve(P, B, A, C);
printf("%lf %lf\n", ans.x, ans.y);
} else printf("-1\n");
}
return 0;
}