//Sumonto Chatterjee
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(a) for(ll ni=0;ni<a;ni++)
#define f1(a,b) for(ll i=a;i<=b;i++)
#define f2(a,b) for(ll j=a;j<=b;j++)
#define f3(a,b) for(ll k=a;k<=b;k++)
#define fr(a,b) for(ll r=a;r>=b;r--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define vll vector<long long int>
#define LL (ll)
void solve()
{
	ll n, m, x;
	cin>>n>>m>>x;
	ll row_no, col_no;
	col_no=x/n;
	row_no=x%n;
	if(row_no)
		col_no++;
	else
		row_no=n;

	cout<<m*(row_no-1)+col_no<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll t; cin>>t; while(t--)
	solve();
}
