#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]; fact[0] = 1; for(int i = 1; i <= n; i++)fact[i] = fact[i-1] * i; inv[n] = mint(1) / fact[n]; for(int i = n; i >= 1; i--)inv[i-1] = inv[i] * i; auto comb=[&](int N,int K){ if(N < K)return mint(0); 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] * mint(n).pow(n-i); } if(m != 1) ans = (mint(n).pow(n) - ans) / (n - 1); cout << ans.val() << endl; }