// Arup Guha
// 3/18/2022
// Solution to 2022 SER Division 1 Problem B: Circle Bounce

import java.util.*;

public class circlebounce {

	final public static long MOD = 1000000007L;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		long a = stdin.nextLong();
		long b = stdin.nextLong();
		long n = stdin.nextLong();
		
		/*** The key idea behind this solution is that the bounces march around the circle subtending
		     equal angles each time. Specifically, if let the angle theta = arctan(a/b), then the
			 amount of the circle we rotate counterclockwise is pi - 2*theta. Thus, we just need to
			 get the rotation matrix for rotating (pi - 2*theta) degrees counterclockwise. In general,
			 the clockwise rotation matrix is:
			 
							[cos theta    -sin theta]
							[sin theta 	   cos theta]
							
			So, to rotate -theta, since cos is an even function and sin is odd, the matrix is
			
							[cos theta    sin theta]
							[-sin theta   cos theta]	

			Now, we just need to calculate cos(pi-2*theta) and sin(pi-2*theta). Using the usual formulas
			for sin, cos subtraction, we finally find that cos(pi-2*theta) = (a*a-b*b)/(a*a+b*b) and
			sin(pi-2*theta) = (2*a*b)/(a*a+b*b).
			
			Thus, the transformation is just this matrix raised to the power n+1, since we do n+1 bounces.
			Finally, the negative of the item in [0][0] of the exponentiated matrix is the desired x value
			because our starting location is (-1, 0). Normally, we would multiply this matrix by the starting
			point. But, since all we need is the x coordinate, I just extracted the answer from the matrix.
			
		***/
		
		// Create the individual items that will make the entries of our matrix.
		long sinNum = (2*a*b)%MOD;
		long cosNum = (a*a-b*b)%MOD;
		if (cosNum < 0) cosNum += MOD;
		
		// We need to use the mod inverse of this! 
		long den = (a*a+b*b)%MOD;
		den = extendedEuclideanAlgorithm(MOD, den)[1];
		if (den < 0) den += MOD;
		
		// Now I am ready to form the matrix!
		long[][] m = new long[2][2];
		m[0][0] = (cosNum*den)%MOD;
		m[1][1] = m[0][0];
		m[0][1] = (sinNum*den)%MOD;
		m[1][0] = ((MOD-sinNum)*den)%MOD;
		
		// It's n+1 because we want to know where it goes AFTER the nth bounce.
		long[][] multMat = exp(m, n+1);
		
		// We start our ray at (-1, 0) so we want the negative of the top left of the matrix.
		System.out.println(((MOD-multMat[0][0])%MOD));
	}
	
	// Returns mat raised to the power exp, using matrix exponentiation.
	public static long[][] exp(long[][] mat, long exp) {
	
		// Just the identity matrix.
		if (exp == 0) return identity(mat.length);
		
		// Savings here!
		if (exp%2 == 0) {
			long[][] tmp = exp(mat, exp/2);
			return mult(tmp, tmp);
		}
		
		// Regular exponential breakdown.
		long[][] tmp = exp(mat, exp-1);
		return mult(tmp,mat);
	}
	
	// Returns matrix a times matrix b.
	public static long[][] mult(long[][] a, long[][] b) {
	
		// Store result here.
		long[][] c = new long[a.length][b[0].length];
		
		// Go through each row of a, column of b.
		for (int i=0; i<a.length; i++) {
			for (int j=0; j<b[0].length; j++) {
			
				// We add up these terms to make one entry.
				for (int k=0; k<b.length; k++)
					c[i][j] = (c[i][j] + a[i][k]*b[k][j])%MOD;
			}
		}
		
		return c;
	}
	
	// Returns the n by n identity matrix.
	public static long[][] identity(int n) {
		long[][] res = new long[n][n];
		for (int i=0; i<n; i++)
			res[i][i] = 1;
		return res;
	}
	
 	// Returns b inverse mod a in res[1]. Note - value returned could be negative.
 	// Only works if a and b are ints due to the multiplication in the code.
	public static long[] extendedEuclideanAlgorithm(long a, long b) {
		if (b==0)
			return new long[]{1,0,a};
		else {
			long q = a/b;
			long r = a%b;
			long[] rec = extendedEuclideanAlgorithm(b,r);
			return new long[]{rec[1], rec[0] - q*rec[1], rec[2]};
		}
	}	
}