#include<bits/stdc++.h>
#define ll long long int
using namespace std;


ll n,m,k;

void solve(){
  cin >> n >> m >> k;
  if(n==1 && m==1){
    cout<<"1"<<endl;
  }else {
      int x = (k-1)/n;
      int y = (k-1)%n;
       cout<<(y*m + (x+1))<<endl;
  }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t; cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


