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