/***************
Code Submitted by Saumya Singh 
Netaji Subhas University of Technology
CF : @saumya_singh203
****************/

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    long long t = 1;
    cin >> t;
    while (t--)
    {
        int n, m, x, add, r, c;
        cin >> n >> m >> x;

        c = (x - 1) / n;
        r = (x - 1) % n;

        cout << (r)*m + (c + 1) << endl;

        

    }
}