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

int main() {
	int t;
	scanf("%d", &t);
	while (t--) {
		ll n, m, k;
		scanf("%lld%lld%lld", &n , &m, &k);
		ll line = (k % n) == 0? n : k % n;
		ll col = (k + n - 1) / n; 
		printf("%lld\n", m * (line - 1) + col);
		
	}
	return 0;
}
