# coding: utf-8 # Your code here! a,b,n=map(int,input().split()) l=[0,1] mod=10**9+7 for i in range(n-1): l.append((a*l[-1]%mod+b*l[-2]%mod)%mod) print(l[-1])