import java.io.*; import java.util.*; public class Main_yukicoder673 { private static Scanner sc; private static Printer pr; private static void solve() { final int MOD = 1_000_000_007; long b = sc.nextLong(); long c = sc.nextLong(); long d = sc.nextLong(); pr.println(f(d, MOD, c % MOD, b % MOD)); } private static long f(long n, int MOD, long c, long b) { long[] a = {c, c * b % MOD, 0, 1}; long[] x = {0, 1}; while(n > 0) { if (n % 2 != 0) { long tmp0 = (x[0] * a[0] + x[1] * a[1]) % MOD; long tmp1 = (x[0] * a[2] + x[1] * a[3]) % MOD; x[0] = tmp0; x[1] = tmp1; } long tmp0 = (a[0] * a[0] + a[1] * a[2]) % MOD; long tmp1 = a[1] * (a[0] + a[3]) % MOD; long tmp2 = a[2] * (a[0] + a[3]) % MOD; long tmp3 = (a[3] * a[3] + a[1] * a[2]) % MOD; a[0] = tmp0; a[1] = tmp1; a[2] = tmp2; a[3] = tmp3; n /= 2; } return x[0]; } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes())); pr = new Printer(System.out); solve(); // pr.close(); pr.flush(); // sc.close(); } static String INPUT = null; private static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }