#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ long long D; cin >> D; long long x,y; cin >> x >> y; long long g = gcd(x,y); long long dx = x/g,dy = y/g,answer = 0; long long v = min(x,(D-y)*dy)/dx; answer = g*(v/dy); long long v2 = min(D-x,y*dy)/dx; answer = max(answer,g*(v2/dy)); x /= g; y /= g; answer *= x*x+y*y; cout << answer << "\n"; } }