import numpy as np def solve() -> None: a = np.array([list(map(float, input().split())) for _ in range(2)]) res = np.linalg.eigh(a) d = np.diag(np.cbrt(res.eigenvalues)) p = res.eigenvectors a = np.linalg.inv(p) @ d @ p for i in range(2): for j in range(2): print(f"{a[i, j]:.5f}", end=" \n"[j == 1]) for _ in range(int(input())): solve()