#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double  dou;
typedef long double ld;
typedef  int I;
using namespace std;
#define  E endl
/*
 _  _  _  _  _ _
|               \    |`\              /`|
|      /`\       \   |  \   ------   /  |
|     /   \      /   |   \  \    /  /   |
|     \_ _/     /    |    \  \  /  /    |
|              /     |     \  \/  /     |
|             /      |      \    /      |
|             \      |  |`\  \  /  /`|  |
|     /``\     \     |  |  \  \/  /  |  |
|    /    \     \    |  |   \____/   |  |
|    \    /      \   |  |            |  |
|     \__/       /   |  |            |  |
|_ _ _ _ _ _ _ _/    |_ |            | _|
*/
void yes()
{
    cout << "YES" << E;
}
void no()
{
    cout << "NO" << E;
}
ll t,mod=1e9+7;
#define loop(a,n) for(int i=a;i<n;i++)
#define loopj(a,n) for(int j=a;j<n;j++)
#define loopk(a,n) for(int k=a;k<n;k++)
#define loopl(a,n) for(int l=a;l<n;l++)
#define loopp(a,n) for(int p=a;p<n;p++)
#define loop_r(a,n) for(int i=n-1;i>=a;i--)
#define loop_Jr(a,n) for(int j=n-1;j>=a;j--)
#define loop_it(m,it) for(it=m.begin();it!=m.end();it++)
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define TC  cin>>t ;while(t--)
int main()
{
    speed;
    TC
    {
        ll n,m,x;
        cin>>n>>m>>x;
        ll val=x/n,y=x%n;
        if(y==0)
           cout<<val+(n-1)*m<<E;
        else
           cout<<val+1+(y-1)*m<<E;
    }
    return 0;
}
