#include using namespace std; using mint = atcoder::modint1000000007; int main(){ long long n, k, m; cin >> n >> k >> m; mint ans, fact[n+1], inv[n+1], npow[n+1]; fact[0] = npow[0] = 1; for(int i = 1; i <= n; i++){ fact[i] = fact[i-1] * i; npow[i] = npow[i-1] * n; } inv[n] = 1 / fact[n]; for(int i = n; i >= 1; i--)inv[i-1] = inv[i] * i; auto comb=[&](int N,int K){return fact[N] * inv[N-K] * inv[K];}; for(int i = 1; i <= n; i++){ if(k % i == 0)ans += comb(n-1, i-1) * fact[i-1] * npow[n-i]; } if(m != 1) ans = (npow[n] - ans) / (n - 1); cout << ans.val() << endl; }