Bifurcation#1848

Bifurcation

2 seconds
256 megabytes
Very easy

Let us denote two sequences of real numbers and . Define a sequence of complex numbers by z(k) = x(k) + i y(k).

Let \mathrm{FFT}_N(k, z) be defined. Similarly, \mathrm{FFT}_N(k, x) and \mathrm{FFT}_N(k, y) are defined.

Given the calculated values \mathrm{FFT}_N(k, z), restore the values \mathrm{FFT}_N(k, x) and \mathrm{FFT}_N(k, y).

Input

The first line contains an integer (1 \leq N \leq 2^{30}, is a power of two). Then six non-negative integers , , , , , follow, each not exceeding . For convenience, the value \mathrm{FFT}_N(k, z) is calculated by the formulas:

\mathrm{FFT}_N(k, z).\mathrm{real} = ((A + B \cdot k)\ \mathrm{xor}\ (C \cdot k)) \cdot 10^{-3}
\mathrm{FFT}_N(k, z).\mathrm{imag} = ((D + E \cdot k)\ \mathrm{xor}\ (F \cdot k)) \cdot 10^{-3}

where \mathrm{FFT}_N(k, z).\mathrm{real} and \mathrm{FFT}_N(k, z).\mathrm{imag} are the real and imaginary parts, respectively.

Then (1 \leq M \leq 10^5), the number of queries, is given. Then integers q_i (0 \leq q_i \leq N) follow.

Output

The output should contain lines. In the -th line, print the values \mathrm{FFT}_N(q_j, x) and \mathrm{FFT}_N(q_j, y). The output values must differ from the correct ones by no more than 10^{-4}.

Examples

Example 1

Loading
Loading