There are atmospheric layers above the ground, ordered from bottom to top. The reflection rate of the -th layer is .
Initially, an amount of light reaches the ground. Whenever light reaches the ground, the ground emits all of that light upward again.
When light travels upward and reaches the -th layer, of the current amount of light is reflected back to the ground, and the rest passes upward. Light that passes through all layers escapes into space and never returns.
Reflected light reaches the ground again, and the ground emits it upward again. This process repeats infinitely.
Find the total amount of light that reaches the ground after infinite time. The initial amount is also included in the total.
The answer may be rational. If the answer is written as an irreducible fraction , print .
Here, denotes the modular inverse of modulo .
Definition of modular inverse
The answer to this problem may not be an integer. Therefore, if the answer is written as an irreducible fraction , you should print .
Here, is called the modular inverse of .
For an integer , its modular inverse modulo is an integer satisfying
We write such a value as .
For example, when ,
so .
If is prime and is not divisible by , Fermat's little theorem gives
Thus, the modular inverse can be computed in time using fast exponentiation.
Input
The input is given in the following format.
Output
Print the total amount of light that reaches the ground after infinite time, modulo .
If the answer is written as an irreducible fraction , print .
Constraints
- .
- ().
- All input values are integers.
Subtasks
Samples
처음에는 만큼의 빛이 지면에 도달한다.
그 후 방출된 빛의 인 이 다시 지면에 도달하고, 그 다음에는 의 인 가 다시 지면에 도달한다.
따라서 총량은
이다.
이므로 정답은 이다.
해설
관리자가 작성한 해설을 별도 페이지에서 볼 수 있어요.