#P7385. 「EZEC-6」跳一跳
「EZEC-6」跳一跳
Background

Xiao A has recently become obsessed with the game "Jump Jump".
Problem Description
The rules of the "Jump Jump" game played by Xiao A are as follows:
- Set a counter , and initialize it to .
- If you jump to the next tile but do not land on its center, gain point and reset to .
- If you jump to the next tile and land on its center, gain points and double .
- If the next tile is a special tile and you land on its center, gain an extra points.
- The game ends when you fail to jump to the next tile, or when you have finished jumping all tiles.
It is known that there are tiles in total, numbered from to (excluding the starting tile).
The probability that Xiao A jumps to the next tile but does not land on its center is . The probability that he jumps to the next tile and does land on its center is . The remaining is the probability that he fails to jump to the next tile.
Compute his expected score, modulo .
Input Format
The first line contains three integers .
The second line contains an integer , indicating that there are special tiles.
The next lines each contain two integers , indicating the index of a special tile and its extra bonus score. It is guaranteed that all are distinct.
Output Format
Output one integer, the expected score.
3 0 100
0
14
3 100 0
0
3
3 0 0
0
0
3 0 100
3
1 10
2 10
3 10
44
114 5 14
3
14 15
92 65
100 100
190259152
Hint
[Sample 1 Explanation]
Xiao A always jumps to the next tile and lands on its center, so the expected score is points.
[Sample 2 Explanation]
Xiao A always jumps to the next tile but does not land on its center, so the expected score is points.
[Sample 3 Explanation]
Xiao A can never jump to the next tile, so the expected score is points.
[Sample 4 Explanation]
Xiao A always jumps to the next tile and lands on its center, so the expected score is points.
[Constraints and Notes]
This problem uses bundled testdata.
In the table below, a slash means there is no special restriction.
| Subtask | Points | ||||
|---|---|---|---|---|---|
| / | |||||
| / | |||||
| / | |||||
| / | |||||
| / | |||||
| / | |||||
| / | |||||
For of the testdata, , , , , .
Translated by ChatGPT 5