import sys import numpy as np def solve() -> None: input = sys.stdin.readline a = np.array([list(map(float, input().split())) for _ in range(2)]) d, p = np.linalg.eigh(a) d = np.diag(np.cbrt(d)) a = p @ d @ np.linalg.inv(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()