#11. 名無声
名無声
Background
After a month of intense practice on Codeforces, Atom has honed his skills and is finally ready for an official contest. However, fate still seems to have a challenge in store for him…
Problem Statement
Due to certain special and indescribable reasons, Atom is forced to skip exactly of Professor E’s classes. The timing of these events is random, and for Atom, each class has an equal probability of being skipped, with the total number of missed classes exactly equal to .
Atom has a predictive model that estimates the probability of being called upon in each class by Professor E, where . Atom wants to calculate the expected number of times he will be called upon when he’s absent (i.e., the expected number of missed classes where he’s called upon), with the result modulo .
Input
The input consists of lines:
- The first line contains two positive integers and , representing the total number of classes and the number of classes Atom will skip.
- The next lines each contain two integers and , representing the probability that Atom will be called upon in the class.
Output
Output a single integer, the expected number of times Atom will be called upon while absent, modulo .
Example
Input 1
3 1
0 1
0 1
6 6
Output 1
332748118
Example Explanation
Atom has 3 classes, and he needs to skip 1 class. Therefore, the probability of being forced to skip each class is , and the probabilities of being called in each class are and , respectively.
The only situation in which he will be caught is if he skips the 3rd class, with a probability of .
In modulo , is represented as .
Constraints
- , and
In the modulo context, can be represented as , where is the modular inverse of modulo .
Hint: Fermat's Little Theorem is a useful tool in number theory. For a prime , if an integer is not divisible by , then , which implies that . Therefore, is the modular inverse of modulo .
相关
在下列比赛中: