QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#18882. Dstorv

Statistiques

In a straight line, there is hand objects and flower objects moving in consistent speed. All hand objects move toward the left, and all flower objects move toward the right. The total number of objects are $N$.

As the speed is consistent, no object of same type will collide to each other. However, there is a chance that the flower and hand might collide. In such case, one of them disappears, and other continues to move in the same direction in speed.

Which one to be removed, is determined by a probability. Flower object disappears with probability $\frac{r}{r+h}$. Hand object disappears with probability $\frac{h}{r+h}$. $r, h$ are the integers given as an input.

After a sufficient amount of time, there will be no collision, as hands would've all gone left, and flowers would've all gone right. Your task is to calculate the probability that there is exactly $A$ flower object and $B$ hand object remaining after all the collision.

Input

The first line of the input contains three integers $N, r, h$. ($1 \le N \le 5\,000, 0 \le r, h \le 1\,000\,000, 1 \le r + h$)

The next line contains a string of length $N$ consisting of two character R, H. This denotes the initial placement of objects in left-to-right order. If a character is R, it denotes a flower object. If a character is H, it denotes a hand object.

The last line contains two integers $A, B$. ($0 \le A, B \le N, 1 \le A + B \le N$)

Output

It can be shown that the answer can be represented as $\frac{P}{Q}$, where $P, Q$ are coprime integer and $Q \neq 0$ $(\mod 10^9 + 7)$.

Output the value of $P \times Q^{-1}$ mod $10^9 + 7$.

Examples

Input 1

4 1 1
RHRH
1 1

Output 1

250000002

Note

The answer for the sample is $\frac{1}{4}$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.