import sys import math from collections import deque,Counter #sys.setrecursionlimit(10**7) int1=lambda x: int(x)-1 inp=lambda :int(input()) mi=lambda :map(int,input().split()) li=lambda :list(mi()) mi1=lambda :map(int1,input().split()) li1=lambda :list(mi1()) mis=lambda :map(str,input().split()) lis=lambda :list(mis()) from collections import defaultdict """ d=defaultdict(int) #初期値 0 d=defaultdict(lambda:1) #初期値 1 """ mod=10**9+7 Mod=998244353 INF=10**18 ans=0 def matmul(A,B,mod): # A,B: 行列 res = [[0]*len(B[0]) for _ in [None]*len(A)] for i, resi in enumerate(res): for k, aik in enumerate(A[i]): for j,bkj in enumerate(B[k]): resi[j] += aik*bkj resi[j] %= mod return res def matpow(A,p,mod): #A^p mod M if p%2: return matmul(A, matpow(A,p-1,mod),mod) elif p > 0: b = matpow(A,p//2,mod) return matmul(b,b,mod) else: return [[int(i==j) for j in range(len(A))] for i in range(len(A))] a,b=mi() n=inp() x=[[2*a,b-a**2],[1,0]] y=matpow(x,n-1,mod) z=matmul(y,[[2*a],[2]],mod) print(z[0][0])