#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){   
    int t;
    cin>>t;

    while(t--){
        ll n,m,x;
        cin>>n>>m>>x;
        x--;
        ll col=x/n;
        ll row=x%n;
        cout<<row*m+col+1<<endl;
    }
}

