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]) B = M @ np.diag([e0, e1]) @ M.T ret.append("{:1.5f} {:1.5f}\n".format(B[0][0], B[0][1])) ret.append("{:1.5f} {:1.5f}\n".format(B[1][0], B[1][1])) print("".join(ret))