from sys import stdin import numpy as np input = stdin.readline def cb(a): if a >= 0: return pow(a, 1 / 3) else: return -pow(-a, 1 / 3) T = int(input()) ret: list[str] = [] for _ in range(T): a, b = map(float, input().split()) c, d = map(float, input().split()) A = np.array([[a, b], [c, d]]) eigval, eigvec = np.linalg.eigh(A) M = np.array([[eigvec[0][0], eigvec[0][1]], [eigvec[1][0], eigvec[1][1]]]) e0 = cb(eigval[0]) e1 = cb(eigval[1]) m0 = eigvec[0][0] m1 = eigvec[0][1] m2 = eigvec[1][0] m3 = eigvec[1][1] # B = M @ np.diag([e0, e1]) @ M.T # ret.append("{:1.5f} {:1.5f}".format(B[0][0], B[0][1])) # ret.append("{:1.5f} {:1.5f}".format(B[1][0], B[1][1])) ret.append("{:1.5f} {:1.5f}".format(m0 * m0 * e0 + m1 * m1 * e1, m0 * m2 * e0 + m1 * m3 * e1)) ret.append("{:1.5f} {:1.5f}".format(m2 * m0 * e0 + m3 * m1 * e1, m2 * m2 * e0 + m3 * m3 * e1)) print(*ret, sep="\n")