#include <bits/stdc++.h>
typedef long long ll;
#define f(i,a,n) for(long long i=a;i<n;i++)
using namespace std;
int main()
{
 ll t;
 cin>>t;
 while(t--)
 {
     ll n,m,x;
     cin>>n>>m>>x;
     ll row=x%n-1;
     if(row<0)row=n-1;
     ll col=x/n;
     if(x%n==0)col--;
     cout<<m*(row)+col+1<<endl;
 }
 
}

// cout<<"YES"<<endl;
// cout<<"NO"<<endl;zz