#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll tc;  cin >> tc;
    while (tc--)
    {
        ll n, m, x;  cin >> n >> m >> x;
        ll a, b, c, d, e;

        b = (x - 1)/n + 1;
        a = (b - 1) * n;
        a = a + 1;
        c = x - a + 1;

        ll ans, ans2;
        ans = (c - 1) * m;
        ans2 = ans + b;

        cout << ans2 <<"\n";
    }
    return 0;
}