#include using namespace std; typedef long long ll; signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); ll mod = 1e9+7; ll a,b,n; cin>>a>>b>>n; ll x[3]; x[0]=0,x[1]=1,x[2]=a; for(int i=3;i<=n;i++){ x[i%3] = (a*x[(i+2)%3])%mod + (b*x[(i+1)%3])%mod; x[i%3] %= mod; if(i==n){ cout << x[i%3] << "\n"; return 0; } } }