#include<iostream>
#define ULL unsigned long long
using namespace std;
ULL transfer(ULL n,ULL m,ULL tar) {
ULL y = (tar - 1) / n + 1;
ULL x = tar - n * (y - 1);
ULL x0 = 1 + m * (x - 1);
ULL ans = (y - 1) + x0;
return ans;
}
int main() {
ULL t = 0;
ULL n = 0, m = 0, tar = 0;
cin >> t;
for (ULL i = 1; i <= t; i++) {
cin >> n >> m >> tar;
cout << transfer(n, m, tar)<<endl;
}
return 0;
}