#include using namespace std; const long long INF = 1e18; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int T; cin>>T; while(T--) { long x, y, D; cin>>D>>x>>y; long ans = 0; for(long t=0; t<1<<20; t++) { long j = x - t*y; long i = y + t*x; if(i<0 || i>D || j<0 || j>D) break; ans = max(ans, abs(x*i - y*j)); } for(long t=0; t> -1*1<<20; t--) { long j = x + t*y; long i = y - t*x; if(i<0 || i>D || j<0 || j>D) break; ans = max(ans, abs(x*i - y*j)); } cout<