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 s=new Scanner(System.in); try{ int a=s.nextInt(); int b=s.nextInt(); String t=s.next(); BigInteger time=new BigInteger(t); BigInteger tomod=new BigInteger("10"); tomod=tomod.pow(9); tomod=tomod.add(BigInteger.valueOf(7)); String temp=String.valueOf((a+b)/2); BigInteger ans=new BigInteger(temp); ans=ans.modPow(time,tomod); System.out.print(ans.toString()); } catch(Exception e){ System.out.print(e); } finally{ s.close(); } } }