from math import* t=int(input()) for _ in range(t): d,x,y=map(int,input().split()) g=gcd(x,y) ans=0 for i,j in(-y//g,x//g),(y//g,-x//g): if i<0: m=x//abs(i) if j<0: m=min(m,y//abs(j)) else: m=min(m,(d-y)//j) else: m=(d-x)//i if j<0: m=min(m,y//abs(j)) else: m=min(m,(d-y)//j) bx,by=x+m*i,y+m*j ans=max(ans,abs(x*by-bx*y)) print(ans)