Nate's math teacher thinks he watches too much anime and not enough time studying for their algebra test. Nate insists that he's already prepared for the test, but in order to prove it, he has to solve the following problem that his teacher gave him.
Given $a$, $n$, and that $x^2 -a x + 1 = 0$, find $b$ such that $x^(2 n) -b x^n + 1 = 0$.
The first line of input contains a single integer $T$, the number of test cases. The next $T$ lines of input each contain two space-separated integers $a$ and $n$, respectively, the values in the equation.
*Constraints*
$1 <= T <= 10^5$
$| a |, | n | <= 10^(18)$
For each of the $T$ test cases, output in its own line a single integer, $b$, that satisfies the equation. Since the answer can get quite large, output only the positive remainder when $b$ is divided by $10^9 + 7$, a prime number. It can be proven that $b$ is always an integer.
## Input
The first line of input contains a single integer $T$, the number of test cases. The next $T$ lines of input each contain two space-separated integers $a$ and $n$, respectively, the values in the equation.*Constraints*$1 <= T <= 10^5$ $| a |, | n | <= 10^(18)$
## Output
For each of the $T$ test cases, output in its own line a single integer, $b$, that satisfies the equation. Since the answer can get quite large, output only the positive remainder when $b$ is divided by $10^9 + 7$, a prime number. It can be proven that $b$ is always an integer.
[samples]
**Definitions**
Let $ T \in \mathbb{Z} $ be the number of test cases.
For each test case $ k \in \{1, \dots, T\} $:
- Let $ n_k \in \mathbb{Z} $ be the number of rounds.
- For each round $ i \in \{1, \dots, n_k\} $, let $ (a_i, b_i, c_i) \in \mathbb{Z}^3 $ be given with $ a_i, b_i, c_i \geq 1 $.
Let $ A_0 = 0 $, $ D_0 = 0 $.
For round $ i $:
- $ A_i^- = A_{i-1} + D_{i-1} $ (aggressivity before action)
- Choose one of three actions:
1. **Action 1**: Deal $ a_i $ damage, set $ D_i = D_{i-1} + 1 $, $ A_i = A_i^- $
2. **Action 2**: Deal $ b_i $ damage, set $ D_i = D_{i-1} $, $ A_i = A_i^- + c_i $
3. **Action 3**: Deal $ 0 $ damage, set $ D_i = D_{i-1} $, $ A_i = A_i^- $
**Constraints**
1. $ 1 \leq T \leq 10 $
2. $ 1 \leq n_k \leq 100 $ for each test case
3. $ \sum_{k=1}^T n_k \leq 100 $
4. $ 1 \leq a_i, b_i, c_i \leq 10^9 $
**Objective**
Maximize total damage over $ n_k $ rounds:
$$
\max \sum_{i=1}^{n_k} \text{damage}_i
$$
over all valid sequences of actions.