Great Pow!

No attempts yetTime limit10sMemory limit64 MB

Problem

Write the power aba^b as powa(b)\mathrm{pow}_a(b).

Then define powa0(a)=a\mathrm{pow}_a^0(a) = a and powak+1(a)=powa(powak(a))\mathrm{pow}_a^{k+1}(a) = \mathrm{pow}_a\bigl(\mathrm{pow}_a^k(a)\bigr) for k0k \ge 0.

Given aa and kk, compute powak(a)\mathrm{pow}_a^k(a), the value of the tower built from k+1k+1 copies of aa:

aaaaa^{a^{a^{\cdots^{a}}}}

The tower is evaluated from the top down. For k=2k = 2, note that (aa)aa(aa)(a^a)^a \neq a^{(a^a)}, and the value you need is the latter.

Input

The first line contains aa and kk separated by a space. (1a1091 \le a \le 10^9, 0k1090 \le k \le 10^9)

Output

Print powak(a)\mathrm{pow}_a^k(a) modulo a+1a+1. The value itself can be enormous, so only the remainder is printed.

Hint

pow23(2)=2222=65536\mathrm{pow}_2^3(2) = 2^{2^{2^{2}}} = 65536, so print 65536 modulo 3, which is 1.