#include long long solve(int D, int x, int y) { int l = 0, r = D, m; long long xx, yy; while (l < r) { m = (l + r + 1) / 2; xx = x - (long long)y * m; yy = y + (long long)x * m; if (xx >= 0 && yy <= D) l = m; else r = m - 1; } long long ans = (long long)x * x + (long long)y * y; return ans * l; } int main() { int T, D, x, y; scanf("%d", &T); while (T--) { scanf("%d %d %d", &D, &x, &y); printf("%lld\n", solve(D, x, y)); } fflush(stdout); return 0; }