#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;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNhc3NlcnQ+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+IFQgc3FyKFQgeCkgeyByZXR1cm4geCAqIHg7IH0KdGVtcGxhdGUgPHR5cGVuYW1lIFQ+IFQgYWJzKFQgeCkgeyByZXR1cm4geCA8IDA/IC14IDogeDsgfQoKaW50IG1haW4oKQp7CglpbnQgazsKCWNpbiA+PiBrOwoJd2hpbGUgKGstLSkKCXsKCQl1bnNpZ25lZCBsb25nIGxvbmcgdywgaCwgbjsKCQljaW4gPj4gdyA+PiBoID4+IG47CgkJdW5zaWduZWQgbG9uZyBsb25nIGwgPSAwLCByID0gbWluKGgsIHcpLCBjOwoJCXdoaWxlIChsIDwgcikKCQl7CgkJCWMgPSAobCArIHIgKyAxKSAvIDI7CgkJCXVuc2lnbmVkIGxvbmcgbG9uZyB0ID0gaCAvIGM7CgkJCWlmICgodyAvIGMpID49IChuICsgdCAtIDEpIC8gdCkKCQkJCWwgPSBjOwoJCQllbHNlCgkJCQlyID0gYyAtIDE7CgkJfQoJCWNvdXQgPDwgbCA8PCBlbmRsOwoJfQoJCglyZXR1cm4gMDsKfQ==