#include using namespace std; const double eps = 0.00000000001; int main(){ cout << fixed << setprecision(5); int T; cin >> T; for (int i = 0; i < T; i++){ vector> M(2, vector(2)); for (int j = 0; j < 2; j++){ for (int k = 0; k < 2; k++){ cin >> M[j][k]; } } if (M[0][1] == 0 && M[1][0] == 0){ cout << cbrt(M[0][0]) << ' ' << "0.00000" << endl; cout << "0.00000" << ' ' << cbrt(M[1][1]) << endl; } else { double tr = M[0][0] + M[1][1]; double det = M[0][0] * M[1][1] - M[0][1] * M[1][0]; vector eigen = {(tr + sqrt(tr * tr - 4 * det)) / 2, (tr - sqrt(tr * tr - 4 * det)) / 2}; vector> D(2, vector(2, 0)); for (int j = 0; j < 2; j++){ D[j][j] = eigen[j]; } vector> P(2, vector(2)); for (int j = 0; j < 2; j++){ vector> M2 = M; for (int k = 0; k < 2; k++){ M2[k][k] -= eigen[j]; } int p = 0; if (abs(M2[0][0]) + abs(M2[0][1]) < abs(M2[1][0]) + abs(M2[1][1])){ p = 1; } P[j][0] = M2[p][1]; P[j][1] = -M2[p][0]; } double det2 = P[0][0] * P[1][1] - P[1][0] * P[0][1]; vector> Pinv = P; swap(Pinv[0][0], Pinv[1][1]); Pinv[0][1] *= -1; Pinv[1][0] *= -1; for (int j = 0; j < 2; j++){ for (int k = 0; k < 2; k++){ Pinv[j][k] /= det2; } } vector> ans(2, vector(2, 0)); for (int j = 0; j < 2; j++){ for (int k = 0; k < 2; k++){ for (int l = 0; l < 2; l++){ for (int m = 0; m < 2; m++){ ans[j][m] += P[j][k] * cbrt(D[k][l]) * Pinv[l][m]; } } } } for (int j = 0; j < 2; j++){ for (int k = 0; k < 2; k++){ cout << ans[j][k]; if (k < 1){ cout << ' '; } } cout << endl; } } } }