import numpy as np def cb(a): if a >= 0: return pow(a, 1 / 3) else: return -pow(-a, 1 / 3) T = int(input()) 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.eig(A) M = np.array([[eigvec[0][0], eigvec[1][0]], [eigvec[0][1], eigvec[1][1]]]) e0 = cb(eigval[0]) e1 = cb(eigval[1]) B = np.linalg.inv(M) * np.diag([e0, e1]) * M print("{:1.5f}".format(B[0][0]), "{:1.5f}".format(B[0][1])) print("{:1.5f}".format(B[1][0]), "{:1.5f}".format(B[1][1]))