#include<bits/stdc++.h>
using namespace std;

int main(){
	int t;

	cin>>t;
	long long n,m,x,i,j,ans;
	while (t--)
	{
		cin>>n>>m>>x;
		i=(x-1)%n;
		j=(x-1)/n;
		ans=(i*m)+j+1;
		cout<<ans<<endl;
	}

}