def gcd(a, b): return a if b == 0 else gcd(b, a % b) def area(a, b, c, d): return abs(a * d - b * c) def solve(D, x, y): g = gcd(x, y) grad_y = x // g grad_x = y // g l = min((D - x) // grad_x, y // grad_y) return area(x, y, x + grad_x * l, y - grad_y * l) T = int(input()) for t in range(T): D, x, y = map(int, input().split()) if x > y: x, y = y, x if x == 0: print(y * y) else: print(max(solve(D, x, y), solve(D, y, x)))