#include
#include
#include
#define mod 7528443412579576937ull
using namespace std;
typedef unsigned long long ull;
ull qmul(ull x , ull y)
{
ull ans = 0;
while(y)
{
if(y & 1) ans = (ans + x) % mod;
x = (x + x) % mod;
y >>= 1;
}
return ans;
}
struct matrix
{
int n , m;
ull num[2][2];
matrix()
{
n = m = 0 , memset(num , 0 , sizeof(num));
}
matrix operator*(matrix a)
{
matrix t;
t.n = n , t.m = a.m;
int i , j , k;
for(i = 0 ; i >= 1;
}
return t;
}
int main()
{
ull b , d , n , x , y , ans;
scanf("%llu%llu%llu" , &b , &d , &n);
x = b , y = (d - b * b) / 4;
A.n = 1 , A.m = 2 , A.num[0][0] = 2 , A.num[0][1] = b;
B.n = 2 , B.m = 2 , B.num[0][1] = y , B.num[1][0] = 1 , B.num[1][1] = x;
ans = (A * qpow(B , n)).num[0][0];
if(y && n % 2 == 0) ans = (ans + mod - 1) % mod;
printf("%llu\n" , ans);
return 0;
}