import numpy as np import sys sys.setrecursionlimit(10 ** 6) def MI(): return map(int, sys.stdin.readline().split()) def main(): md = 10 ** 9 + 7 b,c,d=MI() b,c=b%md,c%md m=[[c,0],[1,1]] m=np.array(m,dtype="i8") pm=np.eye(2,dtype="i8") while d>0: if d&1: pm=np.dot(pm,m) pm%=md d>>=1 m=np.dot(m,m) m%=md a0=[0,b*c%md] a0=np.array(a0,dtype="i8") ans=np.dot(a0,pm)[0]%md print(ans) main()