Alice and Bob want to travel from Pui Ching Middle School (PCMS) to La Salle College (LSC).
In this world, PCMS and LSC are located on opposite sides of the same road. PCMS is located at the start of the road, while LSC is located at the end of the road. There are two pedestrian crossings with traffic lights in front of both schools. Both traffic lights just turned from green to red at time 0.
Refer to the following figure for the layout.
It takes 1 unit time to cross the road, and takes $$$C$$$ unit time to walk from the start of the road to the end of the road. The traffic light of the pedestrian crossing in front of PCMS operates in a period of $$$A$$$ unit time. It means that the traffic light would be red for $$$A$$$ unit time, then green for $$$A$$$ unit time, and so on, alternating every $$$A$$$ units.
Formally, you may cross the road if you arrive at the crossing in front of PCMS in time $$$A$$$, $$$A+1$$$, ..., $$$2A-1$$$, $$$3A$$$, $$$3A+1$$$, ..., $$$4A-1$$$, ...
Similarly, the traffic light of the pedestrian crossing in front of LSC operates in a period of $$$B$$$ unit time.
Alice would take the pedestrian crossing in front of PCMS to cross the road first, then travel along the road to LSC, while Bob would travel along the road to LSC first, then take the pedestrian crossing in front of LSC.
Find the number of pairs $$$(u, v)$$$ where $$$0 \leq u \leq U$$$, $$$0 \leq v \leq V$$$ and satisfies the following conditions:
Each input contains multiple test cases. The first line contains the number of test cases $$$T$$$ $$$(1 \leq T \leq 100)$$$. The description of the test cases follows.
The first and only line of each test case contains five integers $$$A$$$, $$$B$$$, $$$C$$$, $$$U$$$, $$$V$$$ ($$$1 \leq A, B \leq 10^5$$$, $$$1 \leq C, U, V \leq 10^9$$$).
It is guaranteed that the sum of $$$A + B$$$ over all test cases does not exceed $$$2 \times 10^5$$$.
For each test case, output a single integer on a new line: the number of pairs $$$(u, v)$$$ that satisfy the conditions.
33 2 2 5 5314 159 265 358 9792025 20 25 20252025 20262026
2 49141 10221041660
55 145 990758033 183587786 1770965371 1274 114817991 539087542 366293156529 2 42793654 337687912 5362366942 465 57138389 522674854 135110507172 7 829280391 447601408 938200233
6291814931 116390044533 44532871738 15622352866 18970828916
In the first test case of Sample 1, the only two satisfied $$$(u, v)$$$ are $$$(0, 1)$$$ and $$$(3, 2)$$$.
When $$$u=0$$$, $$$v=1$$$:
When $$$u=3$$$, $$$v=2$$$:
All other $$$(u, v)$$$ where $$$0 \leq u \leq 5, 0 \leq v \leq 5$$$ do not satisfy the third condition.
| Название |
|---|


