#include <bits/stdc++.h>
using namespace std;
void solve(){
long long int a,b,k;
cin>>a>>b>>k;
long long int diff = a - b;
if(k==1){
cout<<0;
}
else if(k==2){
cout<<min(a,b);
}
else if(diff > 0){ // diff is positive so 1 6 2 8 3 10 4 12 5 14 7 16 pattern
// 0 50 10 60 20 70 30 80 40 90 50 100
// a b && a/b = 5
long long int div = a/b;
if(k <= div + 1){
cout<<b * (k - 1)<<"\n";
return;
}
k -= (div + 1);
if(k & 1){
cout<<a+((k/2)*b);
}else{
cout<<(div+(k/2))*b;
}
}else{ //diff will be negative so 1 2 3 4 5 6 7 pattern
// 0 1 3 4 6 7 9
if(k&1){
cout<<b*((k-1)/2);
}else{
cout<<b*((k)/2)+diff;
}
}
cout<<"\n";
}
signed main() {
// your code goes here
int tc;
cin>>tc;
while(tc--){
solve();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnZvaWQgc29sdmUoKXsKICAgIGxvbmcgbG9uZyBpbnQgYSxiLGs7CiAgICBjaW4+PmE+PmI+Pms7CiAgICAKICAgIGxvbmcgbG9uZyBpbnQgZGlmZiA9IGEgLSBiOwogICAgCiAgICBpZihrPT0xKXsKICAgICAgICBjb3V0PDwwOwogICAgfQogICAgZWxzZSBpZihrPT0yKXsKICAgICAgICBjb3V0PDxtaW4oYSxiKTsKICAgIH0KICAgIGVsc2UgaWYoZGlmZiA+IDApeyAvLyBkaWZmIGlzIHBvc2l0aXZlIHNvIDEgNiAgMiAgOCAgMyAgMTAgNCAgMTIgNSAgMTQgNyAgMTYgICAgIHBhdHRlcm4KICAgICAgICAvLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDAgNTAgMTAgNjAgMjAgNzAgMzAgODAgNDAgOTAgNTAgMTAwICAgIAogICAgICAgIC8vICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhICBiICAmJiBhL2IgID0gNSAKICAgIAogICAgICAgIGxvbmcgbG9uZyBpbnQgZGl2ID0gYS9iOwogICAgICAgIAogICAgICAgIGlmKGsgPD0gZGl2ICsgMSl7CiAgICAgICAgICAgIGNvdXQ8PGIgKiAoayAtIDEpPDwiXG4iOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIAogICAgICAgIGsgLT0gKGRpdiArIDEpOwogICAgICAgIGlmKGsgJiAxKXsKICAgICAgICAgICAgY291dDw8YSsoKGsvMikqYik7CiAgICAgICAgfWVsc2V7CiAgICAgICAgICAgIGNvdXQ8PChkaXYrKGsvMikpKmI7CiAgICAgICAgfQogICAgICAgIAogICAgICAgIAogICAgfWVsc2V7IC8vZGlmZiB3aWxsIGJlIG5lZ2F0aXZlIHNvIDEgMiAzIDQgNSA2IDcgcGF0dGVybgogICAgICAgICAgICAvLyAgICAgICAgICAgICAgICAgICAgICAgIDAgMSAzIDQgNiA3IDkKICAgICAgICBpZihrJjEpewogICAgICAgICAgICBjb3V0PDxiKigoay0xKS8yKTsgIAogICAgICAgIH1lbHNlewogICAgICAgICAgICBjb3V0PDxiKigoaykvMikrZGlmZjsKICAgICAgICB9CiAgICAgICAgCiAgICB9CiAgICBjb3V0PDwiXG4iOwp9CnNpZ25lZCBtYWluKCkgewoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQogICAgaW50IHRjOwogICAgY2luPj50YzsKICAgIAogICAgd2hpbGUodGMtLSl7CiAgICAgICAgCiAgICAgICAgc29sdmUoKTsKICAgICAgICAKICAgIH0KfQ==