a, b, n = map(int, raw_input().strip().split(' ')) binN = bin(n).lstrip('0b') lenBinN = len(binN) modulus = 10**9 + 7 listOfSuccSquares = [((a + b)/2)%modulus] for i in xrange(lenBinN - 1): listOfSuccSquares.append((listOfSuccSquares[-1]**2)%modulus) expValue = 1 for i in xrange(lenBinN): if binN[-(i + 1)] == '1': expValue = (expValue * listOfSuccSquares[i])%modulus print expValue