import java.math.BigDecimal; import java.util.Arrays; import java.util.Scanner; class Main { double pow(double a, int n) { double ret = 1; for (; n > 0; n >>= 1, a = a * a) { if (n % 2 == 1) { ret = ret * a; } } return ret; } double[][] pow(double[][] a, int n) { double[][] ret = new double[a.length][a.length]; for (int i = 0; i < ret.length; ++i) ret[i][i] = 1; for (; n > 0; n >>= 1, a = mul(a, a)) { if (n % 2 == 1) { ret = mul(ret, a); } } return ret; } double[][] mul(double[][] a, double[][] b) { double[][] ret = new double[a.length][b[0].length]; for (int i = 0; i < a.length; ++i) { for (int j = 0; j < b[i].length; ++j) { BigDecimal sum=new BigDecimal(0); for (int k = 0; k < a[i].length; ++k) { sum=sum.add(BigDecimal.valueOf(a[i][k]*b[k][j])); } ret[i][j]=sum.doubleValue(); } } return ret; } void solve(int T, double w, double v, double gx, double gy) { double s = Math.sqrt((1 + v) * (1 + v) + w * w); double coe = 0; for (int i = 0; i <= T - 1; ++i) { coe += pow(s, 2 * i); } coe = 1 / coe; double[][] M = { { 1 + v, -w }, { w, 1 + v } }; double[][] revM = { { 1 + v, w }, { -w, 1 + v } }; double[][] g = { { gx }, { gy } }; double[][] src = { { 1 }, { 0 } }; double[][] h = mul(pow(M, T), src); h[0][0] = coe * (g[0][0] - h[0][0]); h[1][0] = coe * (g[1][0] - h[1][0]); for (int i = 0; i <= T - 1; ++i) { double[][] u = mul(pow(revM, T - 1 - i), h); System.out.println(u[0][0] + " " + u[1][0]); } } void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 0; i < n; ++i) { int T = sc.nextInt(); double p = sc.nextDouble(); double w = sc.nextDouble(); double v = sc.nextDouble(); double gx = sc.nextDouble(); double gy = sc.nextDouble(); solve(T, w, v, gx, gy); } } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } public static void main(String[] args) { new Main().run(); } }