#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,m,x;
        cin>>n>>m>>x;
        ll row, col;
        col = (x/n);
        if(x%n != 0)
            col++;
        row = x%n;
        if(row == 0)
            row = n;

        ll ans = (m*(row-1)) + col;
        cout<<ans<<endl;
    }
    return 0;
}
