Sunny and Aubrey decided to spend the day together and have a picnic. They started their morning by preparing a dessert and baked a large, round sweet toast, pre-cut into $$$l$$$ equal slices numbered from $$$0$$$ to $$$l-1$$$ in clockwise order.
The friends decided to decorate it with fresh berries:
A slice of toast is considered ideal if it ends up with both a strawberry and a blueberry on it. Count the total number of ideal slices on the toast.
Each test consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.
Each of the next $$$t$$$ lines contains three integers $$$l$$$, $$$a$$$, and $$$b$$$ ($$$2 \le l \le 22$$$, $$$1 \le a, b \le 21$$$) — the number of slices in the toast and the steps with which Aubrey and Sunny place their berries.
For each test case, print a single integer — the number of ideal slices on the toast.
56 2 310 4 75 1 14 10 2115 20 8
15523
In the first test case the strawberries are on slices $$$0,2,4$$$, and the blueberries are on slices $$$0,3$$$. Only slice $$$0$$$ has both berries.
In the second test case Aubrey visits slices $$$0,4,8,2,6$$$. With a step of $$$7$$$, Sunny visits slices $$$0,7,4,1,8,5,2,9,6,3$$$. All five slices on which Aubrey placed a strawberry receive both berries.
In the fourth test case, the steps $$$10$$$ and $$$21$$$ are equivalent to steps $$$2$$$ and $$$1$$$ modulo $$$4$$$. Both berries appear on slices $$$0$$$ and $$$2$$$.