import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner s = new Scanner(System.in); BigInteger a = s.nextBigInteger(); BigInteger b = s.nextBigInteger(); BigInteger t = s.nextBigInteger(); BigInteger s1 = a.add(b); BigInteger s2 = s1.divide(new BigInteger("2")); BigInteger x1 = (new BigInteger("10")).pow(9); BigInteger x2 = x1.add(new BigInteger("7")); BigInteger ans = s2.modPow(t, x2); System.out.print(ans); } }