#include "bits/stdc++.h"
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-12;

bool isEqual(ld a, ld b) {
	return abs(a - b) <= EPS;
}
bool isGreater(ld a, ld b) {
	return a > b + EPS;
}
bool isSmaller(ld a, ld b) {
	return a + EPS < b;
}


int main() {
#ifdef Half_Blood_Prince
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	int t;
	cin >> t;
	while (t--) {
		ll n, m, x;
		cin >> n >> m >> x;
		ll j = (x + (n - 1)) / n;
		ll i = x % n;
		i = (i == 0 ? n : i);
		cout << (i - 1)*m + j << "\n";
	}

	return 0;
}