N, K, D = map(int, input().split()) def solve(N, K, D): mod = 10**9 + 7 x = ((N - K - 1) // (K - 1)) + 1 f = N - (K - 1) * x if D == 1: return f if f == 1: return pow(D, x, mod) dp = [1] * (x + 1) for _ in range(2, f): for idx in range(1, x + 1): dp[idx] += dp[idx - 1] dp[idx] %= mod cum = 0 p = 1 for a in range(0, x + 1): cum += p * dp[x - a] cum %= mod p *= D p %= mod return (cum * f) % mod print(solve(N, K, D))