import sys input = sys.stdin.readline T=int(input()) for tests in range(T): D,x,y=map(int,input().split()) if x==0: print(y*D) continue if y==0: print(x*D) continue # (z,w) = (x,y) + k(-y,x) # 0<=x-ky<=D # 0<=y+kx<=D # k<=x/y,k<=(D-y)/x,k>=(x-D)/y,k>=-y/x MAX=min(x//y,(D-y)//x) MIN=max((x-D+y-1)//y,(-y+x-1)//x) A1=abs(x*(y+MIN*x)-y*(x-MIN*y)) A2=abs(x*(y+MAX*x)-y*(x-MAX*y)) print(max(A1,A2))