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); long a = Long.parseLong(sc.next()); int b = Integer.parseInt(sc.next()); int n = Integer.parseInt(sc.next()); sc.close(); if(n == 0) ou.println(2); else{ long[] q = new long[n + 1]; q[0] = 2; q[1] = 2 * a; for(int i = 2 ; i <= n ; i++){ long tmp = a * (long)a; tmp %= (int)Math.pow(10 , 9) + 7; q[i] = ((2 * a * (long)q[i - 1] - (tmp - b) * q[i - 2]) % (int)(Math.pow(10 , 9) + 7)); } while(q[n] < 0) q[n] += (long)Math.pow(10 , 9) + 7; ou.println(q[n]); } ou.flush(); } }