import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.util.regex.Pattern; public class Solution { private static final int MODULO = 1000000007; private static long [] readData() { try { final StringBuilder lines = new StringBuilder(); final BufferedReader br = new BufferedReader(new InputStreamReader(System.in, Charset.forName("UTF-8"))); for (String line=null; null != (line = br.readLine()); ) { line = line.trim(); if (!line.isEmpty()) { lines.append(line).append(" "); } } return Pattern.compile("\\s+").splitAsStream(lines.toString()).mapToLong(Long::parseLong).toArray(); } catch (IOException e) { throw new RuntimeException(e); } } private static void assertSize(long [] data, int size) { if (size != data.length) { throw new IllegalArgumentException(String.format("expected %d elements, got: %d", size, data.length)); } } public static int virus(long [] data){ assertSize(data, 3); final long a = data[0]; final long b = data[1]; final long t = data[2]; long virus = 1; for (int i=0; i < t; i++) { virus = Math.round(0.5 * a * virus + 0.5 * b * virus); } return (int) (virus % MODULO); } public static void main(String[] args) { System.out.println(virus(readData())); } }