import sequtils,algorithm,math,tables import sets,intsets,queues,heapqueue,bitops,strutils template times*(n:int,body) = (for _ in 0.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord const MOD = 1000000007 proc pow(c,d:int) : int = # c^d if d == 0 : return 1 if d == 1 : return c mod MOD let pow2 = pow(c,d div 2) mod MOD if d mod 2 == 0 : return (pow2 * pow2) mod MOD return (((pow2 * pow2) mod MOD) * (c mod MOD)) mod MOD proc powSum(c,d:int):int = if d == 0: return 1 if d == 1: return (c + 1) mod MOD let powSum2 = powSum(c,(d-1) div 2) mod MOD if d mod 2 == 1: return (powSum2 * (1 + pow(c,1 + d div 2) mod MOD) mod MOD) mod MOD return ((powSum2 * (1 + pow(c, d div 2) mod MOD) mod MOD) mod MOD + pow(c,d)) mod MOD let b = scan() let c = scan() let d = scan() echo (((b mod MOD * powSum(c,d) mod MOD) mod MOD) + MOD - b mod MOD)mod MOD # b \Sigma{ c ^i }[i=[0,d]]