-- Enter your code here. Read input from STDIN. Print output to STDOUT getIntegers :: IO [Integer] getIntegers = do s <- getLine let r = map read $ words s return r modulus :: Integer modulus = 1000000007 powm :: Integer -> Integer -> Integer -> Integer -> Integer powm b 0 m r = r powm b e m r | e `mod` 2 == 1 = powm (b * b `mod` m) (e `div` 2) m (r * b `mod` m) powm b e m r = powm (b * b `mod` m) (e `div` 2) m r main :: IO () main = do [a,b,t] <- getIntegers let base = fromIntegral $ round $ (0.5 * fromIntegral (a + b)) :: Integer let r = powm base t modulus 1 print r