#include <bits/stdc++.h>
 
#define ll long long int
#define ii pair<int,int>
#define int long long int
 
using namespace std;
 
const int inf = 0x3f3f3f3f;

int32_t main() {
    int t; scanf("%lld",&t);
    while(t--) {
        int n, m, x; scanf("%lld%lld%lld",&n,&m,&x);
        --x;

        int c = (x/n);
        int r = (x%n);
        
        int ans = r*m+c;
        printf("%lld\n",ans+1);
    }
    return 0;
}
