Statement
Pillow has connected light bulbs in a row for Christmas. The bulbs are numbered from to from left to right. When the switch is turned on, bulb lights up with probability . These events are mutually independent.
A block is a maximal consecutive interval of lit bulbs. Its length is the number of bulbs it contains.
Process the following queries.
- : Considering only bulbs through , find the expected sum of the squared lengths of all blocks of lit bulbs.
Bulbs outside the query interval are ignored. In particular, a block that extends outside the interval is cut at the interval's endpoints. If no bulb in the interval is lit, the sum of squared lengths is .
Print each expectation modulo as described in the Output section.
Input
The input is given in the following format.
Output
For each test case, print the answers to its queries in input order, one per line. Do not print blank lines between test cases.
Write an expectation as a reduced fraction . Let . The denominator is not divisible by . For an integer satisfying , print the remainder of modulo . The printed integer must be between and , inclusive.
Constraints
- .
- .
- .
Subtasks
Samples
Consider the first query of the first test case. If bulb lights up, there is one block of length . Otherwise, there are two blocks of length . Each event has probability , so the expectation is . Its representation modulo is .