import sys input = sys.stdin.readline T=int(input()) for tests in range(T): D,x,y=map(int,input().split()) # (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) print(max(abs(MIN),abs(MAX))*(x*x+y*y))