T=int(input()) for _ in range(T): D,x,y=map(int,input().split()) def in_map(x,y): return 0<=x<=D and 0<=y<=D ans=0 ok=0 ng=int(1e9) while ng-ok>1: m=(ok+ng)//2 nx=x-y*m ny=y+x*m if in_map(nx,ny):ok=m else:ng=m ans=max(ans,ok*(x**2+y**2)) ok=0 ng=int(1e9) while ng-ok>1: m=(ok+ng)//2 nx=x+y*m ny=y-x*m if in_map(nx,ny):ok=m else:ng=m ans=max(ans,ok*(x**2+y**2)) print(ans)