#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/2 << endl; continue; } if(b==0){ cout << a*D/2 << endl; continue; } ll x,y; ll c=a*a+b*b; ll g=extgcd(a,b,x,y); if(c%g!=0){ cout << 0 << endl; continue; } ll p=(-c*x/g+b/g-1)/(b/g),q=(D-c*x/g)/(b/g); ll qq=(c*y/g)/(a/g),pp=(c*y/g-D+a/g-1)/(a/g); if(max(p,pp)>min(q,qq)){ cout << 0 << endl; continue; } ll u=max(p,pp),v=min(q,qq); ll X,Y,s,S; X=c*x/g+b*u/g; Y=c*y/g-a*u/g; s=2*max(a,X)*max(b,Y)-(a*b+X*Y+llabs(X-a)*llabs(Y-b)); X=c*x/g+b*v/g; Y=c*y/g-a*v/g; 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; }