#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>

using namespace std;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }

int main()
{
	int k;
	cin >> k;
	while (k--)
	{
		unsigned long long w, h, n;
		cin >> w >> h >> n;
		unsigned long long l = 0, r = min(h, w), c;
		while (l < r)
		{
			c = (l + r + 1) / 2;
			unsigned long long t = h / c;
			if ((w / c) >= (n + t - 1) / t)
				l = c;
			else
				r = c - 1;
		}
		cout << l << endl;
	}
	
	return 0;
}