Sequence#1083

Sequence

10 seconds
128 megabytes
Easy

Given a numerical sequence a_1, a_2, a_3, \ldots, the first term is known, and each subsequent term is calculated using the following formula:

a_i = (a_{i-1} \cdot a_{i-1}) \bmod 10000.

Find the -th term of this sequence.

Input

The first line contains two integers: a_1 and (0 \leq a_1 \leq 10000, 1 \leq n \leq 2000000010).

Output

Print one integer a_n.

Examples

Example 1

Loading
Loading