import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); long b = sc.nextLong() % MOD; long c = sc.nextLong() % MOD; long d = sc.nextLong(); long[][] araay = new long[40][4]; araay[0] = new long[]{c, b * c % MOD, 0, 1}; for (int i = 1; i < 40; i++) { araay[i][0] = (araay[i - 1][0] * araay[i - 1][0] + araay[i - 1][1] * araay[i - 1][2]) % MOD; araay[i][1] = (araay[i - 1][0] * araay[i - 1][1] + araay[i - 1][1] * araay[i - 1][3]) % MOD; araay[i][2] = (araay[i - 1][2] * araay[i - 1][0] + araay[i - 1][3] * araay[i - 1][2]) % MOD; araay[i][3] = (araay[i - 1][2] * araay[i - 1][1] + araay[i - 1][3] * araay[i - 1][3]) % MOD; } long[] ans = new long[]{0, 1}; for (int i = 39; i >= 0 && d > 0; i--) { if (d >= (1L << i)) { d -= (1L << i); long[] next = new long[2]; next[0] = (araay[i][0] * ans[0] + araay[i][1] * ans[1]) % MOD; next[1] = (araay[i][2] * ans[0] + araay[i][3] * ans[1]) % MOD; ans = next; } } System.out.println(ans[0]); } }