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