#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926535
#define ll long long int 
#define ulli unsigned long long int 
#define mod 1000000007
#define f(i,l,r) for(i=l;i<r;i++)
#define fr(i,l,r)  for(i=l;i<=r;i++)
#define n1 cout<<"\n"
#define pb(x) push_back(x)
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);   
   ll t;
   cin>>t;
   while(t--)
   {
       ll n,m,x,ans,C,R;
       cin>>n>>m>>x;
       C=(x-1)/n;
       R=x-n*C;
       C++;
       ans=m*(R-1)+C;
       cout<<ans,n1;
   }
}