Recursion
Recursion-16
Recursion-17
Recursion-18
~/algor $ cat problems/rekursiya-tez-daraja
Fast exponentiation
Medium
1000 ms
128 MB
45%
You are given integers $a$, $b$ and $m$. Find $a^{b} \bmod m$. Assume $0^{0} = 1$.
Input
One line with three integers: $a$, $b$ and $m$.
Output
One integer — $a^{b} \bmod m$ (from $0$ to $m - 1$).
Note
$0 \le a \le 10^{9}$
$0 \le b \le 10^{18}$
$1 \le m \le 10^{9} + 7$
Examples
Input #1
2 10 1000
Output #1
24
Input #2
3 0 7
Output #2
1