def f(x): if x==0: return 1,0 if x%2: p,q = f(x-1) return p*c%MOD, (q+b)*c%MOD else: p,q = f(x//2) return p*p%MOD, (p*q+q)%MOD b,c,d = map(int,input().split()) MOD = 10**9+7 print(f(d)[1])