#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
#define CRP(t, x) const t &x
#define OPL(t, x) bool operator<(CRP(t, x)) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
template <typename T>
inline void read(T &x)
{
    int ch = x = 0;
    while (!isdigit(ch)) ch = getchar();
    for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
}
int main()
{
    ll t, n, m, k;
    read(t);
    while (t--)
    {
        read(n), read(m), read(k);
        if (k == n)
            printf("%lld\n", n * (m + 1));
        else
        {
            ll base = m / n;
            ll cnt = (n - m % n) % n;
            printf("%lld\n", base * k + max(0ll, k - cnt) + k);
        }
    }
    return 0;
}