class ModInteger attr_reader :fac, :inv, :finv, :mod def initialize(n, mod: MOD) @mod = mod @fac = [1, 1] @inv = [1, 1] @finv = [1, 1] (2..n).each do |i| @fac[i] = fac[i - 1] * i % mod @inv[i] = mod - inv[mod % i] * (mod / i) % mod @finv[i] = finv[i - 1] * inv[i] % mod end end def combination(n, k) return 0 if n < k return 0 if n < 0 || k < 0 fac[n] * (finv[k] * finv[n - k] % mod) % mod end end N, K, M = gets.split.map(&:to_i) MOD = 10 ** 9 + 7 mi = ModInteger.new(N, mod: MOD) ans = 0 if M == 1 1.upto(N) do |ls| next if K % ls != 0 free = (N - ls) ans += mi.combination(N - 1, ls - 1) * N.pow(N - ls, MOD) ans %= MOD end puts ans else raise end