#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(int i=0;i> T; while(T--){ ll D,a,b; cin >> D >> a >> b; if(a==0){ cout << b*D << endl; continue; } if(b==0){ cout << a*D << endl; continue; } ll p,q; if(a*a+b*b>D*b) p=(a*a+b*b-D*b+a-1)/a; else p=0; if(a*a+b*b>D*a) q=D; else q=(a*a+b*b)/a; ll d=b/gcd(a,b); ll X=a+(q-a)/d*d; ll Y=(-a*X+a*a+b*b)/b; ll s=2*max(a,X)*max(b,Y)-(a*b+X*Y+llabs(X-a)*llabs(Y-b)); X=a-(a-p)/d*d; Y=(-a*X+a*a+b*b)/b; ll S=2*max(a,X)*max(b,Y)-(a*b+X*Y+llabs(X-a)*llabs(Y-b)); cout << max(s,S) << endl; } return 0; }