At the -th second, add a deceleration plan. After the car has traveled for
seconds, its speed will be halved. Note that there can be multiple deceleration plans at the same second. If there are
deceleration plans in one second, its speed will be reduced to
of its original speed.
Assuming the car starts from position at time
with a speed of
and moves in the positive direction, calculate the time it takes to reach position
.
For all operations of the second type, output the result modulo .
The first line contains a positive integer(
), representing the number of operations.
The nextlines each contain two integers
and
(
,
), representing the type of operation and its parameter.
For all operations of the second type, output a single integer on a new line, representing the result modulo
.