#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mpi map<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define pl pair<ll,ll>
#define pi pair<int,int>
#define forn(i,n) for(ll i=0;i<n;i++)
#define ff first
#define ss second
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf       1000000000000
#define MOD       1000000007
ll binpow(ll a,ll b,ll m){
    a%=m;
    ll res=1;
    while(b>0){
        if(b&1)
            res=res*a%m;
        a=a*a%m;
        b>>=1;
    }
    return res;
}
void solve(){
    ll n,m,x;
    cin>>n>>m>>x;
    ll c=x/n;
    if(x%n)
    c++;
    ll r=x%n;
    if(r==0)
    r=n;
    if(c)
    r-=1;
    ll ans=m*(r);
    ans+=c;
    cout<<ans;
}

int main() {
    ll t=1;
    cin>>t;
    while(t--){
        solve();
		cout<<endl;
    }
    return 0;
}