def mod_pow(b, e, m): r = 1 b %= m while e > 0: if e % 2 == 1: r = (r * b) % m e >>= 1 b = (b * b) % m return int(r) inp = input().split() print(mod_pow(int(0.5 * (int(inp[0]) + int(inp[1]))), int(inp[2]), pow(10, 9) + 7))