#P2220. [HAOI2012] 容易题
[HAOI2012] 容易题
Description
There is a sequence of length consisting of positive integers, where every element lies in .
You are given some constraints ( cannot be ). Let the product of the sequence be . Compute the sum of the products over all valid sequences.
In other words, let be the set of all valid sequences , and compute
The answer is taken modulo .
Input Format
The first line contains three positive integers . Here, and are as described above, and is the number of constraints.
Each of the next lines contains two positive integers , representing the constraint .
Output Format
Output a single integer on one line: the answer.
If there is no valid sequence, output .
3 4 5
1 1
1 1
2 2
2 3
4 3
90
Hint
Sample Explanation #1
cannot be , cannot be , and cannot be , so there are the following possible sequences:
| Sequence | Product |
|---|---|
Constraints
- For of the testdata, , , .
- For another of the testdata, .
- For of the testdata, .
- For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号