#include <bits/stdc++.h>

using namespace std;
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,avx,bmi2")
//#include "ext/pb_ds/assoc_container.hpp"
//#include "ext/pb_ds/tree_policy.hpp"
//using namespace __gnu_pbds;
//template<class T> using oredered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long

const int maxn = 1e5, inf = 8e18, mod = 1e9 + 7;

void solve() {
    int n, m;
    cin >> n >> m;
    if (n >= m) exit(-1);
    int x;
    cin >> x;
    vector<int> a(n,0);
    for (int i = 0; i < m; i++) {
        a[i % n] = x - a[i % n];
    }
    cout << accumulate(a.begin(), a.end(), 0ll) << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
// wow1