//#include #include #include #include #include #include #include #include // string, to_string, stoi #include // vector #include // min, max, swap, sort, reverse, lower_bound, upper_bound #include // pair, make_pair #include // tuple, make_tuple #include // int64_t, int*_t #include // printf #include // map #include // queue, priority_queue #include // set #include // stack #include // deque #include // unordered_map #include // unordered_set #include // bitset #include // isupper, islower, isdigit, toupper, tolower using namespace std; //using namespace atcoder; using ll = long long; #define all(A) A.begin(),A.end() using vll = vector; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) using Graph = vector>>; ll mod = 1e9+7; vector>> matrixpow; void prematrixpow(vector matrix) { ll N = matrix.size(); matrixpow.assign(70, vector(N, vll(N))); rep(h, N) { rep(w, N) { matrixpow[0][h][w] = matrix[h][w]; } } rep(k, 69) { rep(h, N) { rep(w, N) { ll S = 0; rep(i, N) { S += matrixpow[k][h][i] * matrixpow[k][i][w]; S %= mod; } matrixpow[k + 1][h][w] = S; } } } } vector modmatrixpow(ll K) { ll P = K; ll N = matrixpow[0].size(); vector res(N, vll(N, 0)); rep(i, N) { res[i][i] = 1; } rep(j, 70) { if (P % 2 != 0) { vector res2(N, vll(N, 0)); rep(h, N) { rep(w, N) { ll S = 0; rep(i, N) { S += matrixpow[j][h][i] * res[i][w]; S %= mod; } res2[h][w] = S; } } res = res2; } P /= 2; } return res; } int main(){ ll B,C,D; cin>>B>>C>>D; B%=mod; C%=mod; vector A={{1,0},{C,C}}; prematrixpow(A); auto AN=modmatrixpow(D-1); ll an=0; an+=C*B; an%=mod; an*=AN[1][1]; an+=AN[1][0]*B; an%=mod; cout<