#include<bits/stdc++.h>
#define int long long
#define read(x) scanf("%lld",&x)
#define print(a,c) printf("%lld%c",a,c)
using namespace std;

int n,m,x;
signed main(){
    int T;
    read(T);
    while(T--){
        read(n),read(m),read(x);
        int r=x%n;
        if(r==0) r=n;
        int c=x/n+(x%n>0);
        print((r-1)*m+c,'\n');
    }
    return 0;
}