#include<bits/stdc++.h>
using namespace std;
#define endl            "\n"
#define ll				long long int
#define f(n) 			for(int i=0;i<n;i++)
#define fo(n)			for(int j=0;j<n;j++)
#define ff 				first
#define ss 				second
#define pb 				push_back
#define pii 			pair<int,int>
#define vi 				vector<int>
#define vp 				vector<pii>
#define test            int tt; cin>>tt; while(tt--)
#define mod 			998244353
void fastio()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("ain.txt", "r", stdin);
	freopen("aout.txt", "w", stdout);
#endif
}

int main()
{
	fastio();
	test{
		ll n, m , x;
		cin >> n >> m >> x;
		ll q = (x + n - 1) / n;
		ll w = x % n;
		if (w == 0)w = n;
		w--;
		w *= m;
		cout << q + w << endl;
	}

}