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 in = new Scanner(System.in); final double A_PROB = 0.5; final double B_PROB = 0.5; final BigInteger MOD_CONSTANT = new BigInteger("1000000007"); int a = in.nextInt(); int b = in.nextInt(); BigInteger t = new BigInteger(in.next()); final int GROWTH_FACTOR = (int) ((A_PROB * a) + (B_PROB * b)); BigInteger middleman = new BigInteger(String.valueOf(GROWTH_FACTOR)); double numCells = 1; long answer = 0; middleman = middleman.modPow(t, MOD_CONSTANT); answer = middleman.longValue(); System.out.println(answer); } }