#include <iostream>
using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--){
        long long  n,m,x;
        cin>>n>>m>>x;
        long long  col = (x-1)/n;
        long long  row = (x-1)%n;
        long long ans =  m*row+col;
        cout <<ans+1<<endl;
        
    }
	// your code goes here
	return 0;
}
