#P1630. Sum of Powers Modulo

    ID: 14916 Type: Default 1000ms 256MiB

Sum of Powers Modulo

Sum of Powers Modulo

Given two positive integers a and b, compute the remainder when the sum

\[1^b + 2^b + \cdots + a^b\]

is divided by \(10^4\). All operations are performed modulo \(10^4\).

inputFormat

The input contains two space-separated integers: a and b.

outputFormat

Output a single integer, which is the value of \(1^b + 2^b + \cdots + a^b \bmod 10^4\).

sample

3 2
14