#include <iostream>
using namespace std;
#define ll long long
ll t,n,m,k,x,y,ans;
int main(){
    cin>>t;
    while(t--){
        cin>>n>>m>>k;
        x=(k-1)/n+1,y=(k-1)%n+1;
        ans=x+(y-1)*m;
        cout<<ans<<endl;
    }
    return 0;
}
			 	 	 	 		  									 	     	