P17217 [ICPC 2017 Nanning R] Five Dimensional Discrete Fourier Transform

Description

The five dimensional discrete fourier transform over a $n_1 \times n_2 \times n_3 \times n_4 \times n_5$ complex array $a[i_1][i_2][i_3][i_4][i_5]$ where $0 \le i_1 \le n_1-1, 0 \le i_2 \le n_2-1, 0 \le i_3 \le n_3-1, 0 \le i_4 \le n_4-1$ and $0 \le i_5 \le n_5 - 1$ is given by: $$ A[j_1][j_2][j_3][j_4][j_5] = \sum_{i_1=0}^{n_1-1} \cdots \sum_{i_5=0}^{n_5-1} a[i_1][i_2][i_3][i_4][i_5] e^{-2 \pi \sqrt{-1} (i_1 j_1 / n_1 + \cdots + i_5 j_5 / n_5)} $$ for $0 \le j_1 \le n_1 - 1, \dots, 0 \le j_5 \le n_5 - 1$. Now comes your turn. For a given real coefficient $\alpha$, suppose $$ a[i_1][i_2][i_3][i_4][i_5] = (i_1 \text{ xor } i_2 \text{ xor } i_3 \text{ xor } i_4 \text{ xor } i_5) e^{\sqrt{-1}(i_1 - i_2 + i_3 - i_4 + i_5) \alpha} $$ Please calculate the value of $$ \frac{1}{(n_1 n_2 n_3 n_4 n_5)^{1.5}} \sum_{j_1=0}^{n_1-1} \cdots \sum_{j_5=0}^{n_5-1} |\text{Re}(A[j_1][j_2][j_3][j_4][j_5])|, $$ where $\text{Re}$ means the real part of a complex number and $|\cdot|$ means the absolute value of a real number.

Input Format

The first line of the input contains an integer $T (1 \le T \le 200)$ indicating the total number of test cases. For each test case, a line contains five integers $n_1, n_2, n_3, n_4, n_5$ where $1 \le n_1, n_2, n_3, n_4, n_5 \le 10$, and a float number $\alpha (-100000 \le \alpha \le 100000)$ with at most $10$ significant digits.

Output Format

For each test case, output the value with the precision of $6$ digits.