import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); BigInteger a = scan.nextBigInteger(); BigInteger b = scan.nextBigInteger(); BigInteger t = scan.nextBigInteger(); BigInteger bi1, bi2, bi3; int exponent = 9; BigInteger p = new BigInteger("10"); BigInteger result = p.pow(exponent); BigInteger l = new BigInteger("7"); BigInteger e = new BigInteger("2"); bi3 = ((a.add(b)).divide(e)).modPow( t, result.add(l)); System.out.print(bi3); } }