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) continue if x+y>D: print(0) continue if x>=y: k=int(min((D-y)//x,x//y)) print(int(k*(x**2+y**2))) else: k=int(min((D-x)//y,y//x)) print(int(k*(x**2+y**2)))