import java.io.*; import java.util.*; import java.math.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); BigInteger a = new BigInteger(scan.next()); BigInteger b = new BigInteger(scan.next()); BigInteger t = new BigInteger(scan.next()); BigInteger e = BigInteger.TEN.pow(9).add(BigInteger.valueOf(7)); BigInteger expected = a.add(b).divide(BigInteger.valueOf(2)).modPow(t, e); System.out.println(expected); } }