#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy ios_base::sync_with_stdio(false);  cin.tie(NULL);cout.tie(NULL);
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define watch(x) cout << #x << " = " << x << endl;
#define endl "\n"
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
typedef long long ll;
typedef unsigned long long ull;
void Open()
{
#ifndef ONLINE_JUDGE
    freopen("standard.in", "r", stdin);
    freopen("standard.out", "w", stdout);
#else
    //freopen("standard.in", "r", stdin);
    //freopen("standard.out", "w", stdout);
#endif
}
const ll mod = int(1e9 + 7), N = 1e5 + 55, oo = int(1e9);
//"The secret of getting ahead is getting started". Mark Twain

//if you get WR, don't try to debug the code too much: think about another idea;
//don't be afraid of letters,letter G doesn't mean  the problem is hard;
//don't stuck in one problem after you gets alot WR ,just jump to the next one

int main()
{
    Ma7moud_7amdy;
    Open_Sesame;;
    int t;
    cin>>t;
    while(t--)
    {
        ll n,m,x;
        cin>>n>>m>>x;
        ll row=(x+n-1)/n-1;
        ll col=x-row*n;
        cout<<m*(col-1)+row+1<<endl;
    }

    return 0;
}
//"There's a way to do it better - find it". Thomas A. Edison
