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

void solve()
{
    int n,m,x;
    cin>>n>>m>>x;
    int c = x/n;
    int r = x%n;
    if(r == 0)
    {
        r = n;
    }
    // cout << r << " " << c << " " << n << " " << m << "\n";
    if(x%n != 0)
    {
        c++;
    }
    cout << (r-1)*m + (c) << "\n";
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif

    int t;t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
