input_vals = list(map(lambda x: int(x),input().split())) a = input_vals[0] b = input_vals[1] t = input_vals[2] expected_num = round(pow(int(0.5*a+0.5*b),t,pow(10,9)+7)) print("{0:.0f}".format(expected_num))