using System.Numerics; using System; public class Hello { public static int MOD = 1000000007; static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var b = long.Parse(line[0]); var c = long.Parse(line[1]); var d = long.Parse(line[2]); getAns(b, c, d); } static void getAns (long b, long c, long d) { if (c == 1) { var res0 = b % MOD; res0 *= d; res0 %= MOD; Console.WriteLine(res0); return; } BigInteger res = b % MOD; res *= c; res %= MOD; BigInteger t = BigInteger.ModPow(c, d, MOD) - 1; res *= t; res %= MOD; var t2 = ModInverse(c - 1, MOD); res *= t2; res %= MOD; Console.WriteLine(res); } public static BigInteger ModInverse(BigInteger a, BigInteger m) { return BigInteger.ModPow(a, m - 2, m); } }