#include #define int long long using namespace std; typedef vector vec; typedef vector mat; const int mod=1e9+7; mat mul(mat &A,mat &B) { mat C(A.size(),vec(B[0].size())); for(int i=0;i0){ if(n&1) B=mul(B,A); A=mul(A,A); n>>=1; } return B; } signed main() { cin.tie(0); ios::sync_with_stdio(false); int a,b,n; cin>>a>>b>>n; mat A(2,vec(2)); A[0][0]=a; A[0][1]=b; A[1][0]=1; A[1][1]=0; A=pow(A,n); cout<