#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll i,j,n,m,x;
        cin>>n>>m>>x;
        ll c=((x-1)/n)+1;
        ll r=x-(c-1)*n;
        ll ans=(r-1)*m+c;
        cout<<ans<<endl;
    }
}
