#include using namespace std; int N, K, D, fact[1000009], inv[1000009], finv[1000009], mod = 1000000007; int main() { cin >> N >> K >> D; int P = N / (K - 1), Q = N % (K - 1); if (Q == 0) Q += K - 1, P++; if (D == 1) cout << Q << endl; else { fact[0] = 1, finv[0] = 1; for (int i = 1; i <= P + Q; i++) { fact[i] = 1LL * fact[i - 1] * i % mod; inv[i] = (i == 1 ? 1 : 1LL * inv[mod % i] * (mod - mod / i) % mod); finv[i] = 1LL * finv[i - 1] * inv[i] % mod; } int ret = 0, pw = 1; for (int i = 0; i <= P; i++) { ret = (ret + 1LL * pw * fact[P + Q - i - 2] % mod * finv[Q - 2] % mod * finv[P - i]) % mod; pw = 1LL * pw * D % mod; } cout << 1LL * ret * Q % mod << endl; } return 0; }