# Enter your code here. Read input from STDIN. Print output to STDOUT a,b,t=map(int,raw_input().strip().split(" ")) mt=0.5*(a+b) M=7+10**9 b=int(mt%M) ans=pow(b, t, M) print int(ans)