import sequtils,strutils,math var B,C,D,ans,p : int64 M : int64 = 1_000_000_007 (B, C, D) = stdin.readline.split.map(parseBiggestInt) if C == 1: echo(((B mod M) * (D mod M)) mod M) quit() proc powInt(n : int64, m : int64, k = 1_000_000_007):int64 = if m == 0: return 1 elif m == 1: return (n mod k) var n2 = n mod k if (m mod 2) == 0: return powInt((n2 * n2) mod k,m div 2, k) mod k else: return (powInt((n2 * n2) mod k,m div 2, k) * n2) mod k proc inv_mod(a : int64):int64 = var b,x,u,q,t : int64 a2 = a b = M x = 1 u = 0 while b > 0: q = a2 div b t = u u = x - q * u x = t t = b b = a2 - q * b a2 = t if x < 0: x += M return x ans = B mod M ans = (ans * (C mod M)) mod M p = powInt(C, D) - 1 if p < 0: p += M ans = (ans * p) mod M ans = (ans * inv_mod(C - 1)) mod M echo ans