#include "iostream"
#include "algorithm"
#include "string.h"
using namespace std;
typedef long long ll;
int main(){
    int t;
    cin >> t;
    while (t--){
        ll n,m,x;
        cin >> n >> m >> x;
        x--;
        ll r = (x % n);
        ll c = x / n;
        cout << m * r +  c + 1<<endl;
    }
    return 0;
}
