#include using namespace std; constexpr int64_t mod = 1000000007; class PairInt { public: int64_t x, y, z; PairInt(int64_t a, int64_t b, int64_t c) { x = a; y = b; z = c; } PairInt mul(PairInt a, PairInt b) { return PairInt{(a.x*b.x%mod + a.y*b.y%mod*a.z) % mod, (a.y*b.x%mod + a.x*b.y) % mod, a.z}; } PairInt power(int64_t n) { PairInt res(1, 0, this->z); while (n) { if (n % 2) res = mul(res, *this); *this = mul(*this, *this); n /= 2; } return res; } }; int main() { int64_t a, b, n; cin >> a >> b >> n; PairInt z(a, 1, b); cout << z.power(n).x * 2 % mod << endl; }