#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define ll unsigned long long
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define vll vector<ll>
#define MAX 100010 // sqrt of MAX
#define MOD 1000000007
#define LMT 10000 // sqrt of MAX
#define LEN 5000005 // MAX primes that can be within range
#define RNG 100032 //
#define sq( x ) ( x * x )
#define chkC(x,n) ( x[n>>6] &  ( 1<<(( n>>1 ) &31)))
#define setC(x,n) ( x[n>>6] |= ( 1<<(( n>>1 ) &31)))
#define SZ 2
 
ll p,q,n,d=1,m=10007;
struct Matrix
{
    ll mat[SZ][SZ];
};
 
Matrix matmul( Matrix A, Matrix B)
{
    Matrix C;
    for(int i=0; i <= d; i++)
    {
        for(int j = 0; j <= d ; j++)
        {
            ll val = 0ll;
            for(int k = 0; k <= d; k++)
            {
                val +=A.mat[i][k]*B.mat[k][j];
            }
            C.mat[i][j] = val;
        }
    }
    return C;
}
 
Matrix matexpo( Matrix BASE, long long p )
{
    if( p==1ll || p==0ll )
        return BASE;
    Matrix R = matexpo(BASE,(ll)p >> 1ll);
    R = matmul(R,R);
    if( p&1ll ) R = matmul( R,BASE );
    return R;
}
 
void print( Matrix ret )
{
    for(int i = 0; i <= d; i++)
    {
        for(int j = 0; j <= d; j++)
            cout<< ret.mat[i][j] << " ";
        cout<<endl;
    }
}
 
 
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //FILE*f=freopen("input.txt","r",stdin);
    //FILE*o=freopen("output.txt","w",stdout);
    Matrix base;
    int t;
    scanf("%d", &t);
    for(int tc = 1; tc <= t; tc++)
    {
        scanf("%llu %llu %llu",&p,&q,&n);
        if(n==0)
            printf("Case %d: 2\n",tc);
        else if(n==1)
            printf("Case %d: %llu\n",tc,p);
        else
        {
            memset(base.mat,0,sizeof(base.mat));
            base.mat[0][0]=p,base.mat[0][1]=-q;
            base.mat[1][0]=1,base.mat[1][1]=0;
            //print(base);
            base=matexpo(base,n-1);
            //print(base);
            ll ans=(base.mat[0][0]*p+base.mat[0][1]*2);
            printf("Case %d: %llu\n",tc,ans);
        }
    }
    //fclose(f);
    //fclose(o);
 
    return 0;
}