#include <iostream>
#define ll long long int
using namespace std;
int main() {
    int t{};
    cin >> t;
    while (t--) {
        ll n{},m{},x{},q{},r{};
        cin >> n >> m >> x;
        q = x / n;
        r = x % n;
        if (r == 0) {
            r = n;
        }
        else
            ++q;
        --r;
        cout << (r * m) + q << "\n";
    }
    return 0;
}
