#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1e9+7
#define inf 1e20
#define endl '\n'
#define all(x) x.begin(), x.end()
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define FORe(i,a,b) for(int i=a;i<=b;i++)
#define print(a,n) for(int i=0;i<n;i++) cout << a[i] << " ";
#define BRUH ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

void solve()
{
    ll n, m, k;
	cin >> n >> m >> k;
	//cout << k << endl;
	ll row, coln;
 
	coln = (k / n);
	row = (k % n);
	if (row == 0)
		row = n - 1;
	else
	{
		row--;
		coln++;
	}
	//cout << i << " " << j << endl;
	ll ans = (m * (row));
	ans = ans + coln ;
	cout << ans << endl;
}

int main()
{
	BRUH
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}
