#include using namespace std; using ld = double; using C = complex; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; for (int q = 0; q < N; q++) { int T; cin >> T; ld p, omega, v, gx, gy; cin >> p >> omega >> v >> gx >> gy; const C A = C{1 + v, -omega}; const C a = pow(A, T); C g{gx - a.real(), gy + a.imag()}; const ld l = norm(A); const ld F = (l == 1 ? T : (pow(l, 2 * T) - 1) / (l * l - 1)); g /= F; vector ans(T); ans[T - 1] = g; for (int i = T - 2; i >= 0; i--) { ans[i] = ans[i + 1] * A; } for (int i = 0; i < T; i++) { cout << fixed << setprecision(50) << ans[i].real() << " " << ans[i].imag() << endl; } } return 0; }