#include #include #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) using ll = long long; using namespace std; template auto vectors(X x, T a) { return vector(x, a); } template auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector(x, cont); } const int mod = 1e9+7; int solve(int n, int k, int d) { int r = 0; while (n >= k) { n -= k-1; r += 1; } if (d == 1) return n; auto dp = vectors(n+1, r+1, 0); auto cnt = vectors(n+1, r+1, 0); dp[0][0] = 1; cnt[0][0] = 1; repeat (x,r) { dp[0][x+1] = dp[0][x] *(ll) d % mod; cnt[0][x+1] = 1; } repeat (y,n-1) { repeat (x,r+1) { ll acc = 0; ll cntacc = 0; repeat (z,x+1) { acc += dp[y][x-z] + cnt[y][x-z] *(ll) dp[0][z] % mod; cntacc += cnt[y][x-z]; } dp[y+1][x] = acc % mod; cnt[y+1][x] = cntacc % mod; } } return dp[n-1][r]; } int main() { int n, k, d; scanf("%d%d%d", &n, &k, &d); printf("%d\n", solve(n, k, d)); return 0; }