import java.io.*; import java.util.*; import java.io.*; import java.math.BigInteger; import java.util.*; public class Solution { static int power(int d, int y) { int temp; if( y == 0) return 1; temp = power(d, y/2); if (y%2 == 0) return temp*temp; else return d*temp*temp; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int x = 10; int y = 9; int a = 0; int b = 0; BigInteger calc, calc2; a = in.nextInt(); b = in.nextInt(); //t = in.nextLong(); BigInteger t = new BigInteger(in.next()); //System.out.println("power example: " + power(x,y)); calc = BigInteger.valueOf((long) (0.5*(a+b))); //System.out.println(calc); calc2 = BigInteger.valueOf((power(x,y) + 7)); BigInteger temp = calc.modPow(t,calc2); System.out.println(temp); in.close(); } }