The snails are climbing a tree. The tree height is $$$h$$$ meters, and snails start at position $$$0$$$.
Each snail has two attributes $$$a$$$ and $$$b$$$ ($$$a > b$$$). Starting from the $$$1$$$-st day, one snail climbs the tree like this: during the daylight hours of the day, he climbs up $$$a$$$ meters; during the night, the snail rests, and he slides down $$$b$$$ meters. If on the $$$n$$$-th day, the snail reaches position $$$h$$$ for the first time (that is, the top of the tree), he will finish climbing, and we say that the snail spends $$$n$$$ days climbing the tree. Note that on the last day of climbing, the snail doesn't necessarily climb up $$$a$$$ meters, in case his distance to the top is smaller than $$$a$$$.
Unfortunately, you don't know the exact tree height $$$h$$$ at first, but you know that $$$h$$$ is a positive integer. There are $$$q$$$ events of two kinds.
You need to deal with all the events in order.
Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then follows their description.
The first line of each test case contains one integer $$$q$$$ ($$$1\le q \le 2\cdot 10^5$$$) — the number of events.
For the following $$$q$$$ lines, the first integer of each line is either $$$1$$$ or $$$2$$$, denoting the event type.
If the event type is $$$1$$$, then three integers $$$a$$$, $$$b$$$, and $$$n$$$ ($$$1\le a,b,n \le 10^9$$$, $$$a>b$$$) follow.
If the event type is $$$2$$$, then two integers $$$a$$$ and $$$b$$$ ($$$1\le a,b \le 10^9$$$, $$$a>b$$$) follow.
It is guaranteed that the sum of $$$q$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, output $$$q$$$ integers in one line, one for each event, in order. Specifically,
531 3 2 52 4 12 3 231 6 5 12 3 12 6 231 4 2 21 2 1 32 10 291 7 3 61 2 1 82 5 11 10 9 71 8 1 21 10 5 81 10 7 72 7 41 9 4 291 2 1 61 8 5 61 4 2 72 9 11 5 1 41 5 2 71 7 1 91 9 1 42 10 8
1 2 5 1 -1 1 1 0 1 1 0 -1 0 0 0 1 8 0 1 0 0 1 0 0 0 0 1
In the first test case, we can determine $$$h=7$$$ through the first message, so we know the second snail and the third snail need to spend $$$2$$$ and $$$5$$$ days respectively to reach the top.
Let's show how the second snail climbs:
In the third test case, the second snail's message contradicts the first snail's, because the second snail says he spent $$$3$$$ days, and he can climb at most $$$1+1+2=4$$$ meters in the first $$$3$$$ days. However, the first snail only needs $$$1$$$ day to climb $$$4$$$ meters.
Name |
---|