#include <bits/stdc++.h>
using ll=long long;
using namespace std;

int main()
{
    ll q;
    cin>>q;
    while(q--)
    {
        ll n,m,x;
        cin>>n>>m>>x;
        ll j=(x-1)/n;
        ll i=x-(j*n)-1;
        cout<<i*m+j+1<<'\n';
    }
}
