import sys parameters = [int(height_temp) for height_temp in input().strip().split(' ')] a = parameters[0] b = parameters[1] t = parameters[2] prob_a = 1 prob_b = 1 for msec in range(0,t): prob_a = prob_a * a prob_b = prob_b * b num_cells = (0.5*prob_a + 0.5*prob_b)%(10**9 + 7) print(int(num_cells))