package yukicoder; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main{ public static void main(String[] args) { new Main().solve(); } final int MOD = 1_000_000_000 + 7; void solve() { Scanner sc = new Scanner(System.in); int H = sc.nextInt(); int W = sc.nextInt(); int K = sc.nextInt(); Prime p = new Prime((int) Math.sqrt(1_000_000_000)); ArrayList fh = p.primeFactorF(H); ArrayList fw = p.primeFactorF(W); long sum = 0; ArrayList dh = enum_div(fh); ArrayList dw = enum_div(fw); for (int i = 0; i < dh.size(); i++) { for (int j = 0; j < dw.size(); j++) { sum += f(dh.get(i), dw.get(j), K, p, H, W); sum = sum % MOD; } } System.out.println(sum * inv(W * H, MOD) % MOD); } long inv(long a, long mod) { long b = mod; long p = 1, q = 0; while (b > 0) { long c = a / b; long d; d = a; a = b; b = d % b; d = p; p = q; q = d - c * q; } return p < 0 ? p + mod : p; } // nの約数を列挙 // 1とnを含む。 ArrayList enum_div(ArrayList f) { ArrayList ret = new ArrayList(); ret.add(1L); for (int i = 0; i < f.size(); i++) { long a = 1; int n = ret.size(); for (int j = 0; j < f.get(i).exp; j++) { a *= f.get(i).base; for (int k = 0; k < n; k++) { ret.add(ret.get(k) * a); } } } return ret; } long f(long x, long y, int k, Prime p, int h, int w) { return totient_function(p.primeFactorF(x), x) % MOD * totient_function(p.primeFactorF(y), y) % MOD * pow(k, h * w % MOD * gcd(x, y) % MOD * (inv(x * y, MOD) % MOD)%MOD) % MOD; } class Prime { long n; ArrayList ps = new ArrayList(); Prime(long n) { this.n = n; ps = primeList((int) Math.sqrt(n)); } boolean[] isPrimeArray(int max) { boolean[] isPrime = new boolean[max + 1]; Arrays.fill(isPrime, true); isPrime[0] = isPrime[1] = false; for (int i = 2; i * i <= max; i++) { if (isPrime[i]) { for (int j = 2; j * i <= max; j++) { isPrime[j * i] = false; } } } return isPrime; } /* * max以下の素数のリストを返す */ ArrayList primeList(int max) { boolean[] isPrime = isPrimeArray(max); ArrayList primeList = new ArrayList(); for (int i = 2; i <= max; i++) { if (isPrime[i]) { primeList.add(i); } } return primeList; } /* * numをprimeListの素数をもとに素因数分解し、因数を ArrayListの形で返す。1は含まれない。 * primeListにはnumの平方根以下の素数が含まれていなければならない。 * */ ArrayList primeFactorF(ArrayList primeList, long num) { ArrayList ret = new ArrayList(); for (int p : primeList) { int exp = 0; while (num % p == 0) { num /= p; exp++; } if (exp > 0) ret.add(new Factor(p, exp)); } if (num > 1) ret.add(new Factor(num, 1)); return ret; } ArrayList primeFactorF(long num) { ArrayList ret = new ArrayList(); for (int p : ps) { int exp = 0; while (num % p == 0) { num /= p; exp++; } if (exp > 0) ret.add(new Factor(p, exp)); } if (num > 1) ret.add(new Factor(num, 1)); return ret; } } class Factor { long base, exp; Factor(long base, long exp) { this.base = base; this.exp = exp; } } /* * 戻り値:約数の和 verified:yukicoder No.278 */ long sum_d(ArrayList fs) { long sum = 1; for (Factor f : fs) { sum *= Long.parseLong((BigInteger.ONE.subtract(pow_big(f.base, f.exp + 1))) .divide(BigInteger.ONE.subtract(BigInteger.valueOf(f.base))).toString()); } return sum; } BigInteger pow_big(long a, long n) { BigInteger A = new BigInteger(String.valueOf(a)); BigInteger ans = BigInteger.ONE; while (n >= 1) { if (n % 2 == 0) { A = A.multiply(A); n /= 2; } else if (n % 2 == 1) { ans = ans.multiply(A); n--; } } return ans; } /* * Eulerのφ関数(Euler's totient function) 1からnまでの自然数のうちnと互いに素なものの個数を数える。 * φ(mn)=φ(m)φ(n) (gcd(m,n)=1) なぜならば、chinese reminder theoremより、 a mod mnと * (a mod n)と(b mod m)は全単射。 φ(p^k)=p^k-p^(k-1)=p^k(1-1/p) * よってφ(p^k*q^k)=n(1-1/p)(1-1/q)という風にできる。 */ long totient_function(ArrayList f, long n) { long ret = n; for (int i = 0; i < f.size(); i++) { ret = ret - ret / f.get(i).base; } return ret; } long gcd(long t1, long t2) { if (t1 < t2) { long d = t2; t2 = t1; t1 = d; } if (t2 == 0) return t1; return gcd(t2, t1 % t2); } long pow(long a, long n) { long A = a; long ans = 1; while (n >= 1) { if (n % 2 == 0) { A = (A * A) % MOD; n /= 2; } else if (n % 2 == 1) { ans = (ans * A) % MOD; n--; } } return ans; } }