Skip to content
UPEEC

Power Modulo

Medium#math#fast-exponentiation· solved by 0 · time limit 2.0 s

Print ab mod (109+7)a^b \bmod (10^9+7).

Multiplying aa by itself bb times is far too slow — use exponentiation by squaring (O(log⁡b)O(\log b)).

Input

Two integers aa and bb.

Output

ab mod 1000000007a^b \bmod 1000000007.

Constraints

0≤a≤1090 \le a \le 10^9, 0≤b≤10180 \le b \le 10^{18}. 00=10^0 = 1.

Sample 1

Input

2 10

Output

1024

Sample 2

Input

3 0

Output

1

Sign in or join free to run and submit your solution.