def main(): from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum from heapq import heapify, heappop, heappush from bisect import bisect_left, bisect_right from copy import deepcopy import copy import random from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_,itemgetter INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!! ''' ''' #p = のところを変更すること。 #limitationも必要なら変更 def nCr(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n-r] % p p = mod1 limitation = 10 ** 6 # N は必要分だけ用意する fact = [1, 1] # fact[n] = (n! mod p) factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) inv = [0, 1] # factinv 計算用 for i in range(2, limitation + 1): fact.append((fact[-1] * i) % p) inv.append((-inv[p % i] * (p // i)) % p) factinv.append((factinv[-1] * inv[-1]) % p) N,K,M = map(int, input().split()) ls = [] for i in range(1,N+1): if K%i == 0: ls.append(i) tmp = 0 for d in ls: tmp += nCr(N-1,d-1,mod1)*fact[d-1]%mod1*pow(N,N-d,mod1)%mod1 tmp %= mod1 if M == 1: print(tmp) else: ans = (pow(N,N,mod1)-tmp)*pow(N-1,mod1-2,mod1)%mod1 print(ans) if __name__ == '__main__': main()