using System; using System.Collections.Generic; using System.IO; using System.Numerics; class Solution { static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ string[] input = Console.ReadLine().Split(' '); BigInteger a = new BigInteger(Int32.Parse(input[0])); BigInteger b = new BigInteger(Int32.Parse(input[1])); BigInteger t = new BigInteger(Int32.Parse(input[2])); BigInteger result = new BigInteger(0); BigInteger modulo = new BigInteger(1000000007); BigInteger half = new BigInteger(2); result = power(a, t, modulo, half) + power(b, t, modulo, half); //result *= half; Console.WriteLine(result); } static BigInteger power(BigInteger a, BigInteger t, BigInteger mod, BigInteger half){ BigInteger res = new BigInteger(1); BigInteger even = new BigInteger(2); a = a % mod; while (t > 0){ if(t % even != new BigInteger(0)){ res = (res * a)%mod; } t = t >> 1; a = (a * a) % mod; } return res / half; } }