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()) print(max(solve(D, x, y), solve(D, y, x)))