AtCoder Regular Contest 176 (Sponsored by Mynavi)
B
Simple Math 4
AtCoder
⌀ 1298
原题
← AC →
翻译中…

Problem Statement

翻译中…

Find the last digit of the remainder when $2^N$ is divided by $2^M - 2^K$.

翻译中…

You are given $T$ test cases, each of which must be solved.

翻译中…

Constraints

翻译中…
  • $1 \le T \le 2 \times 10^5$
  • $1 \le N \le 10^{18}$
  • $1 \le K < M \le 10^{18}$
  • $N,M,K$ are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format, where $\mathrm{case}_i$ represents the $i$-th test case:

翻译中…

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

翻译中…

Each test case is given in the following format:

翻译中…

N M K

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
5
9 6 2
123 84 50
95 127 79
1000000007 998244353 924844033
473234053352300580 254411431220543632 62658522328486675
Output #1
2
8
8
8
4
For the first test case, the remainder of $2^9$ divided by $2^6 - 2^2$ is $32$. Thus, the answer is the last digit of $32$, which is $2$.
题目信息
题号
arc176_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。