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) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); BigInteger t = scan.nextBigInteger(); //System.out.println((Math.pow(10,9)+7)); double pa = 0.5; double pb = 0.5; BigDecimal growthPerMillisecond = new BigDecimal((a * pa) + (b * pb)); //BigInteger growthatNmillisecond = growthPerMillisecond.modPow(t,new BigInteger((Math.pow(10,9)+7))); BigDecimal growthmod = fastModPow(growthPerMillisecond, t, (new BigDecimal((Math.pow(10,9)+7)))); //BigDecimal growthmod = growthatNmillisecond.remainder(new BigDecimal((Math.pow(10,9)+7))); System.out.println(growthmod); } static BigDecimal fastModPow(BigDecimal base, BigInteger exponent, final BigDecimal modulo) { BigDecimal result = BigDecimal.ONE; while (exponent.compareTo(BigInteger.ZERO) > 0) { if (exponent.testBit(0)) // then exponent is odd result = (result.multiply(base)).remainder(modulo); exponent = exponent.shiftRight(1); base = (base.multiply(base)).remainder(modulo); } return result.remainder(modulo); } }