#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:

  1. Set a counter cnt\text{cnt}, and initialize it to 22.
  2. If you jump to the next tile but do not land on its center, gain 11 point and reset cnt\text{cnt} to 22.
  3. If you jump to the next tile and land on its center, gain cnt\text{cnt} points and double cnt\text{cnt}.
  4. If the next tile is a special tile xix_i and you land on its center, gain an extra yiy_i points.
  5. 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 nn tiles in total, numbered from 11 to nn (excluding the starting tile).

The probability that Xiao A jumps to the next tile but does not land on its center is a%a\%. The probability that he jumps to the next tile and does land on its center is b%b\%. The remaining (100ab)%(100-a-b)\% is the probability that he fails to jump to the next tile.

Compute his expected score, modulo 109+710^9+7.

Input Format

The first line contains three integers n,a,bn,a,b.

The second line contains an integer mm, indicating that there are mm special tiles.

The next mm lines each contain two integers x,yx,y, indicating the index of a special tile and its extra bonus score. It is guaranteed that all xx 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 2+4+8=142+4+8=14 points.

[Sample 2 Explanation]

Xiao A always jumps to the next tile but does not land on its center, so the expected score is 1+1+1=31+1+1=3 points.

[Sample 3 Explanation]

Xiao A can never jump to the next tile, so the expected score is 00 points.

[Sample 4 Explanation]

Xiao A always jumps to the next tile and lands on its center, so the expected score is 2+10+4+10+8+10=442+10+4+10+8+10=44 points.

[Constraints and Notes]

This problem uses bundled testdata.

In the table below, a slash means there is no special restriction.

Subtask Points nn aa bb mm
11 =1=1 =50=50 /
22 99 20\le 20 / =0=0
33 1010 /
44 105\le 10^5 =0=0
55 2020 /
66 55 / =0=0 =100=100
77 =100=100 =0=0
88 1515 / =0=0
99 2525 /

For 100%100\% of the testdata, 1n10181\le n\le 10^{18}, 0a,b,a+b1000\le a,b,a+b\le 100, 0mmin(n,105)0\le m\le \min(n,10^5), 1xn1\le x\le n, 1y1001\le y\le 100.

Translated by ChatGPT 5