#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        unsigned long long int n,m,a,b,x;
        cin>>n>>m>>x;
        if(x%n==0){
            b=x/n;
        }else{
            b=x/n+1;
        }
        if(n==1&&m==1){
            cout<<"1\n";
        }else{
        if(x%n==0){
            a=n;
        }else{
            a=x%n;
        }
        unsigned long long int c=(a-1)*m+b;
        cout<<c<<endl;
        }
    }
}