atcoder#ABC271G. [ABC271G] Access Counter
[ABC271G] Access Counter
Score : points
Problem Statement
Takahashi has decided to put a web counter on his webpage. The accesses to his webpage are described as follows:
- For , there is a possible access at o'clock every day:- If
T
, Takahashi accesses the webpage with a probability of percent.- If
A
, Aoki accesses the webpage with a probability of percent. - Whether or not Takahashi or Aoki accesses the webpage is determined independently every time.
- If
- If
T
, Takahashi accesses the webpage with a probability of percent. - If
A
, Aoki accesses the webpage with a probability of percent. - Whether or not Takahashi or Aoki accesses the webpage is determined independently every time.
- There is no other access.
Also, Takahashi believes it is preferable that the -th access since the counter is put is not made by Takahashi himself.
If Takahashi puts the counter right before 0 o'clock of one day, find the probability, modulo , that the -th access is made by Aoki.
Notes
We can prove that the sought probability is always a finite rational number. Moreover, under the constraints of this problem, when the value is represented as with two coprime integers and , we can prove that there is a unique integer such that and . Find this .
Constraints
- is
T
orA
. - , , and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
1 50 50
ATATATATATATATATATATATAT
665496236
The -st access since Takahashi puts the web counter is made by Aoki with a probability of .
271 95 1
TTTTTTTTTTTTTTTTTTTTTTTT
0
There is no access by Aoki.
10000000000000000 62 20
ATAATTATATTTAAAATATTATAT
744124544