MOD = int( 1e9 ) + 7 H, W, K = map( int, input().split() ) def gcd( a, b ): if b == 0: return a return gcd( b, a % b ) def get_prime( x ): res = [] _ = x i = 2 while i * i <= _: if _ % i == 0: res.append( i ) while _ % i == 0: _ //= i i += 1 if _ > 1: res.append( _ ) return res hp, wp = get_prime( H ), get_prime( W ) def phi( x, memo = {} ): if x in memo: return memo[ x ] if H % x == 0: res = x for p in hp: if x % p == 0: res = res // p * ( p - 1 ) memo[ x ] = res return res else: res = x for p in wp: if x % p == 0: res = res // p * ( p - 1 ) memo[ x ] = res return res ans = 0 for a in range( 1, H + 1, 1 ): if a * a > H: break if H % a != 0: continue for b in range( 1, W + 1, 1 ): if b * b > W: break if W % b != 0: continue ans += pow( K, H // a * W // b * gcd( a, b ) % ( MOD - 1 ), MOD ) * phi( a ) * phi( b ) ans %= MOD if b * b == W: break bb = W // b ans += pow( K, H // a * W // bb * gcd( a, bb ) % ( MOD - 1 ), MOD ) * phi( a ) * phi( bb ) ans %= MOD if a * a == H: break aa = H // a for b in range( 1, W + 1, 1 ): if b * b > W: break if W % b != 0: continue ans += pow( K, H // aa * W // b * gcd( aa, b ) % ( MOD - 1 ), MOD ) * phi( aa ) * phi( b ) ans %= MOD if b * b == W: break bb = W // b ans += pow( K, H // aa * W // bb * gcd( aa, bb ) % ( MOD - 1 ), MOD ) * phi( aa ) * phi( bb ) ans %= MOD ans = ans * pow( H * W, MOD - 2, MOD ) % MOD print( ans )