from functools import reduce 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 is_prime( n ): return 1 < n and all( n % i for i in range( 2, int( n ** 0.5 ) + 1 ) ) def factors( n ): return [ i for i in range( 1, int( n ** 0.5 ) + 1 ) if n % i == 0 ] + [ n // i for i in range( 1, int( n ** 0.5 ) + 1 ) if i * i != n and n % i == 0 ] hf, wf = factors( H ), factors( W ) hp, wp = [ v for v in hf if is_prime( v ) ], [ v for v in wf if is_prime( v ) ] def phi( x ): return reduce( lambda a, b: a // b * ( b - 1 ), [ x ] + [ p for p in ( hp if H % x == 0 else wp ) if x % p == 0 ] ) ans = 0 for a in hf: for b in wf: ans += pow( K, H // a * W // b * gcd( a, b ) % ( MOD - 1 ), MOD ) * phi( a ) * phi( b ) ans %= MOD ans = ans * pow( H * W, MOD - 2, MOD ) % MOD print( ans )