#include using namespace std; template class ModInt { int64_t value; public: // constructor inline ModInt(int64_t val = 0) noexcept : value((val >= MOD) ? (val % MOD) : (val < 0) ? ((val + MOD) % MOD) : val) {} // プリミティブ整数型へのキャスト (型の明示:必要) template explicit inline operator Int() const noexcept { return static_cast(value); } inline ModInt inv() const noexcept { return ModInt::pow(value, MOD-2); } inline ModInt& operator+=(ModInt x) noexcept { if ((value += x.value) >= MOD) value -= MOD; return *this; } inline ModInt& operator-=(ModInt x) noexcept { if ((value -= x.value) < 0) value += MOD; return *this; } inline ModInt& operator*=(ModInt x) noexcept { value = (value * x.value) % MOD; return *this; } inline ModInt& operator/=(ModInt x) noexcept { value = (value * x.inv().value) % MOD; return *this; } inline ModInt& operator^=(int64_t x) noexcept { value = (int64_t)pow((int64_t)value, x); value %= MOD; return *this; } inline ModInt operator+(ModInt x) const noexcept { return ModInt(*this) += x; } inline ModInt operator-(ModInt x) const noexcept { return ModInt(*this) -= x; } inline ModInt operator*(ModInt x) const noexcept { return ModInt(*this) *= x; } inline ModInt operator/(ModInt x) const noexcept { return ModInt(*this) /= x; } inline ModInt operator^(int64_t x) const noexcept { return ModInt(*this) ^= x; } inline bool operator==(ModInt x) const noexcept { return value == x.value; } inline bool operator!=(ModInt x) const noexcept { return !(this->operator==(x)); } friend ostream& operator<<(ostream &os, ModInt x) noexcept { os << x.value; return os; } friend istream& operator>>(istream &is, ModInt &x) noexcept { is >> x.value, x.value%=MOD; return is; } static constexpr inline ModInt pow(int64_t n, int64_t p) noexcept { int64_t ret = 1; for(; p > 0; p >>= 1) { if (p & 1) ret = (ret * n) % MOD; n = (n * n) % MOD; } return ret; } }; using modint = ModInt; int main(){ modint b, c; long long n; cin >> b >> c >> n; modint ans; if(c != 1){ ans = (b * c * ((c^n) - 1)) / (c-1); }else{ ans = b * n; } cout << ans << endl; return 0; }