import math T = int(input()) def solve(d, ax, ay): if ay == 0: return ax * d if ax == 0: return ay * d g = math.gcd(ax, ay) stepx = ax//g stepy = ay//g # 左方向に進む(-stepy, stepx) cnt1 = min(ax//stepy, (d - ay)//stepx) # (ax, ay) から cnt1 歩進む bx = ax - stepy*cnt1 by = ay + stepx*cnt1 candi1 = abs(ax * by - ay * bx) # 右方向に進む(stepy, -stepx) cnt2 = min((d - ax)//stepy, ay//stepx) bx = ax + stepy*cnt2 by = ay - stepx*cnt2 candi2 = abs(ax * by - ay * bx) return max(candi1, candi2) for i in range(T): d, ax, ay = map(int, input().split()) print(solve(d, ax, ay))