e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Competitions

Exponentiation

Sequence

In a sequence of numbers a1, a2, a3, ... the first term is given, and the other terms are calculated using the formula:

ai = (ai-1 * ai-1) mod 10000

Find the n-th term of the sequence.

Input

The first row contains the numbers a1 and n (0a110000, 1n2000000010).

Output

Print the value of an.

Time limit 10 second
Memory limit 128 MiB
Input example #1
4 3
Output example #1
256
Input example #2
0 2000000000
Output example #2
0