#include //#include using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; //calculate ceil(a/b) template T ceil(T a, T b){ assert(b != 0); if (a == 0) return 0; if (a > 0 && b > 0) return (a+b-1) / b; else if (a < 0 && b < 0) return (a+b+1) / b; else return a / b; } //calculate floor(a/b) template T floor(T a, T b){ assert(b != 0); if (a == 0) return 0; if (a > 0 && b < 0) return (a-b-1) / b; else if (a < 0 && b > 0) return (a-b+1) / b; else return a / b; } int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int T; cin >> T; while(T--){ ll D, x, y, l1, r1, l2, r2, l, r; cin >> D >> x >> y; //ありうるのは(x-ny, y+nx) (nは整数) //面積の2倍は|n|(x^2+y^2) //0<=x-ny<=D, 0<=y+nx<=D l1 = ceil(x-D, y); r1 = floor(x, y); l2 = ceil(-y, x); r2 = floor(D-y, x); l = max(l1, l2); r = min(r1, r2); if (l>r){ cout << 0 << endl; } else{ cout << max(abs(l),abs(r)) * (x*x+y*y) << endl; } } return 0; }