def main(): try: import pypyjit pypyjit.set_param('max_unroll_recursion=-1') except: pass try: import sys sys.setrecursionlimit(10**7) except: pass from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum from heapq import heapify, heappop, heappush from bisect import bisect_left, bisect_right import copy import random from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_,itemgetter INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython def dot(A1,A2,n): # n:行列のサイズ A = [[0]*n for _ in range(n)] for i in range(n): for j in range(n): for k in range(n): A[i][j] += A1[i][k]%mod1*A2[k][j]%mod1 A[i][j] %= mod1 return A def pow_mat(A,k,n): # A:累乗する行列, k:累乗数, n:行列Aのサイズ P = [[0]*n for _ in range(n)] for i in range(n): P[i][i] = 1 while k: if k&1: P = dot(P,A,n) A = dot(A,A,n) k >>= 1 return P a,b,n = map(int, input().split()) A = [[a,b],[1,0]] ls = pow_mat(A,n-1,2) print(ls[0][0]%mod1) if __name__ == '__main__': main()