#include #define For(i, a, b) for(int i = a; i < b; i++) #define rep(i, n) For(i, 0, n) #define rFor(i, a, b) for(int i = a; i >= b; i--) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() using namespace std; using lint = long long; using ld = long double; int INF = 2000000000; lint LINF = 1000000000000000000; int main() { int t; cin >> t; while (t--) { lint d, x, y; cin >> d >> x >> y; lint l = 0, r = 1000000010; while (r - l > 1) { lint mid = (l + r) / 2LL; lint nx = x - mid * y, ny = y + mid * x; if (0 <= nx && nx <= d && 0 <= ny && ny <= d) { l = mid; } else { r = mid; } } lint l2 = -1000000010, r2 = 0; while (r2 - l2 > 1) { lint mid = (l2 + r2) / 2LL; lint nx = x - mid * y, ny = y + mid * x; if (0 <= nx && nx <= d && 0 <= ny && ny <= d) { r2 = mid; } else { l2 = mid; } } cout << max(l * (x * x + y * y), r2 * (x * x + y * y)) << endl; } }