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