atcoder#ABC208F. [ABC208F] Cumulative Sum

[ABC208F] Cumulative Sum

Score : 600600 points

Problem Statement

For non-negative integers nn and mm, let us define the function f(n,m)f(n, m) as follows, using a positive integer KK.

$\displaystyle f(n, m) = \begin{cases} 0 & (n = 0) \\ n^K & (n \gt 0, m = 0) \\ f(n-1, m) + f(n, m-1) & (n \gt 0, m \gt 0) \end{cases}$

Given NN, MM, and KK, find f(N,M)f(N, M) modulo (109+7)(10 ^ 9 + 7).

Constraints

  • 0N10180 \leq N \leq 10^{18}
  • 0M300 \leq M \leq 30
  • 1K2.5×1061 \leq K \leq 2.5 \times 10^6
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM KK

Output

Print f(N,M)f(N, M) modulo (109+7)(10 ^ 9 + 7).

3 4 2
35

When K=2K = 2, the values f(n,m)f(n, m) for n3,m4n \leq 3, m \leq 4 are as follows.

m=0m = 0 m=1m = 1 m=2m = 2 m=3m = 3 m=4m = 4
n=0n = 0 00
n=1n = 1 11
n=2n = 2 44 55 66 77 88
n=3n = 3 99 1414 2020 2727 3535
0 1 2
0
1000000000000000000 30 123456
297085514