#include using namespace std; #define i64 long long #define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++) i64 b,c,d; i64 MOD = 1e9 + 7; i64 pow(i64 x,i64 y){ i64 res = 1; while(y > 0){ if(y & 1) res = (res * x) % MOD; x = (x * x) % MOD; y >>= 1; } return res; } i64 inv_mod(i64 a, i64 m = MOD) { i64 b, x, u, q, abs_m, tmp; abs_m = (m < 0) ? -m : m; b = m; x = 1; u = 0; while (b > 0) { q = a / b; tmp = u; u = x - q * u; x = tmp; tmp = b; b = a - q * b; a = tmp; } return (x < 0) ? abs_m + x : x; } int main(){ cin >> b >> c >> d; b %= MOD; c %= MOD; /** * bc + bc^2 + ... + bc^d = * b * (c ^ (d + 1) - 1 / (c - 1) - 1 */ i64 sum; if(c == 1) sum = d + 1; else sum = (((pow(c,d + 1) + MOD - 1) % MOD) * (inv_mod((c + MOD - 1) % MOD) % MOD)) % MOD; cout << (b * ((sum + MOD - 1) % MOD)) % MOD << endl; }