// <-- Coded by Pasindu_Piumal -->
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long int
#define ld long double
#define str string
#define F first
#define S second
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair

inline void io_setup(){
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);
}

const int mxN=101;
ull n, m, x, a, b;

void solve() {
	cin >> n >> m >> x;
	/*if(x<=n) {
		cout << m*x << "\n";
		return;
	}*/
	a=x/n;
	if(x%n!=0)a++, b=x%n;
	else b=n;
	cout << (m*(b-1)+a) << "\n";
}

int main() {
	io_setup();
    
	int t;
	cin >> t;
	while(t--) {
		solve();
	}
	
	return 0;
}
