#include <bits/stdc++.h>
#include <cassert>
using namespace std;
using graph = vector<vector<int>>;

int main() {
    int tt;
    cin >> tt;
    while(tt--) {
        long long n, m, x;
        cin >> n >> m >> x;
        long long row = x % n == 0 ? n : x % n;
        cout << (row - 1) * m + (x - row) / n + 1 << endl;
    }
    return 0;
}
