#pragma GCC optimization ("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a; i<b; i++)
#define endl "\n"
void solve()
{
        ll t; cin>>t; 
        f(i,0,t)
        {
                ll n,m,x; cin>>n>>m>>x;
                ll col,row,ans=0;

                col=(x-1)/n,row=(x-(col)*n)%(n+1);
                ans=ans+m*(row-1)+col+1;
                cout<<ans<<"\n";
                
        }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ------------------------------------------------------------------------
solve();


}        