T=int(input()) for _ in range(T): D,x,y=map(int,input().split()) if x==0: print(D*y) continue if y==0: print(D*x) k=max(int(min((D-y)//x,x//y)),int(min((D-x)//y,y//x))) print(int(k*(x**2+y**2)))