#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>
#include <set>
#include <map>
#define  ll long long
#define PII pair<int,int>
using namespace std;
/////////////////////////////
const int N=1e6+100;
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		ll n,m,x;
		cin>>n>>m>>x;
		
		ll l=x/n;
		if(x%n) l++; 
		
		ll h;
		if(x%n==0) h=n;
		else h=x%n;
		
		ll ans=(h-1)*m+l;
		cout<<ans<<endl; 
	}
} 
