import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter ou = new PrintWriter(System.out); int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); long n = Long.parseLong(sc.next()); if(n == 0) ou.println(2); else{ long x = 1; long y = 0; long z = 0; long w = 1; long p = 2 * a; p %= (long)(Math.pow(10 , 9) + 7); long q = b - a * (long)a; q %= Math.pow(10 , 9) + 7; if(q < 0) q += 1000000007; long r = 1; long s = 0; n--; while(n != 0){ if((n & 1) == 1){ long x_tmp, y_tmp, z_tmp, w_tmp; x_tmp = x * p % 1000000007 + y * r % 1000000007; x_tmp %= Math.pow(10 , 9) + 7; y_tmp = x * q % 1000000007 + y * s % 1000000007; y_tmp %= Math.pow(10 , 9) + 7; z_tmp = z * p % 1000000007 + w * r % 1000000007; z_tmp %= Math.pow(10 , 9) + 7; w_tmp = z * q % 1000000007 + w * s % 1000000007; w_tmp %= Math.pow(10 , 9) + 7; x = x_tmp; y = y_tmp; z = z_tmp; w = w_tmp; } long p_tmp, q_tmp, r_tmp, s_tmp; p_tmp = p * p % 1000000007 + q * r % 1000000007; p_tmp %= Math.pow(10 , 9) + 7; q_tmp = p * q % 1000000007 + q * s % 1000000007; q_tmp %= Math.pow(10 , 9) + 7; r_tmp = p * r % 1000000007 + r * s % 1000000007; r_tmp %= Math.pow(10 , 9) + 7; s_tmp = r * q % 1000000007 + s * s % 1000000007; s_tmp %= Math.pow(10 , 9) + 7; p = p_tmp; q = q_tmp; r = r_tmp; s = s_tmp; n >>= 1; } x = 2 * a * x % 1000000007 + 2 * y % 1000000007; x %= Math.pow(10 , 9) + 7; while(x < 0) x += Math.pow(10 , 9) + 7; ou.println(x); } ou.flush(); sc.close(); } }