#include <bits/stdc++.h>
using namespace std;
int main()
{       
    int t=1;
     cin>>t;
    while(t--)
    {
       long long int n=3,m=5;
		cin>>n>>m;
		long long  int k=11;
		cin>>k;	
         long long  int n1=0,m1=0;
        m1=k/n;
        n1=k%n;
        //cout<<m1<<endl;
        //cout<<n1<<endl;
        long long int cnt=0;
        if(n1!=0)
        {
           cnt=m*(n1-1)+m1+1;
        }
        if(n1==0)
        {
           cnt=m*(n-1)+m1;
         }
         cout<<cnt<<endl;
	}
    return 0;
}