cho.sh
Notes
Loading...

Power Sum

Time limit

2s

Memory limit

128 MB

Problem

Given positive integers N and K, compute the following value modulo 1,000,000,007.

1^K + 2^K + 3^K + ... + N^K

Input

The first line contains two positive integers, N and K. N is at most 10^9, and K is at most 50.

Output

Print the remainder of 1^K + 2^K + 3^K + ... + N^K divided by 1,000,000,007.