#include <bits/stdc++.h>#include <limits>
#define el '\n'
#define vi vector<long long>
#define pb push_back
#define ll long long
#define ld long double
#define mod 1000000007
#define O_o ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sieve vector<bool> primes = siev();
#define MAX 100005
using namespace std;
ll isPrime(ll n);
vector<bool> siev();
ll gcd(ll n1,ll n2);
ll lcm(ll n1, ll n2);





int main()
{
    O_o


    ll t;cin >> t;
    for(int w = 0; w<t; w++)
    {
        ll n,m,x; cin >> n >> m >> x;
        ll col= (x+n-1)/n, row = x%n;
        if(row==0){row=n;}
        cout << col+(row-1)*m << el;
    }
}











ll gcd(ll n1,ll n2)
{
    ll a=max(n1,n2), b=min(n1,n2);
    while(a%b!=0)
    {
        ll temp=b;
        b=a%b;
        a=temp;
    }
    return b;
}

ll lcm(ll n1, ll n2)
{
    return (n2*n1)/gcd(n1,n2);
}

vector<bool> siev()
{
    vector<bool> siv(MAX, 1);
    for(ll i = 2; i*i<=MAX; i++)
    {
        if(siv[i]==1)
        {
            for(ll j = i*i; j<=MAX; j+=i)
            {
                siv[j]=0;
            }
        }
    }
    siv[0]=0;
    siv[1]=0;
    return siv;
}

ll isPrime(ll n)
{
    if(n==1){return 1;} if(n==2){return 0;}
    int divs=0;
    for(int i = 2; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            divs++;
        }
    }
    if(divs>0){return 1;}else{return 0;}
}
