/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 0; lli n = 0ll, m = 0ll, x = 0ll;
    cin >> t;
    while (t--)
    {
        cin >> n >> m >> x;
        lli i = (x + n) % n;
        lli j = (x + n) / n;
        if (i == 0ll)
        {
            i = n; --j;
        }
        cout << (j + 1ll * (i - 1ll)*m) << "\n";
    }
}