# Enter your code here. Read input from STDIN. Print output to STDOUT def power(x,y): if y==0: return 1 temp=power(x,y/2) if y%2==1: return temp*x*temp%(10**9+7) else: return temp*temp%(10**9+7) a,b,t=map(int,raw_input().split(' ')) r=int(0.5*a+0.5*b) l=power(r,t) print int(l)%(10**9+7)