def ceildiv(x, y): assert 0 < y return -(-x//y) def solve(D, x, y): lo = ceildiv(-x, y) if lo < ceildiv(y-D, x): lo = ceildiv(y-D, x) hi = ceildiv(D-x, y) if hi > y//x: hi = y//x if lo >= hi: return 0 return max(abs(hi), abs(lo)) * (x**2 + y**2) T = int(input()) for _ in range(T): d, x, y = map(int, input().split()) print(solve(d, x, y))