#P4426. [HNOI/AHOI2018] 毒瘤
[HNOI/AHOI2018] 毒瘤
Description
There was once a "Duliu" (pinyin).
Duliu recently discovered the secret to mass-producing "duliu" problems. Consider a data-structure problem of the following type: given an array, you need to support several quirky update operations (for example, adding a number to a range, or taking the square root on a range), and support querying range sums. Duliu considered such update operations, numbered . When Duliu wants to set a data-structure problem, he selects some of these update operations and turns them into a problem.
Of course, such a problem might be unsolvable. Through clever mathematical reasoning, Duliu revealed the relationships among these update operations: there are pairs of mutually exclusive update operations, and the -th pair is the -th operation and the -th operation. When a problem contains both and , the problem becomes unsolvable. On the other hand, if a problem contains no mutually exclusive pairs, then the problem is solvable. In addition, Duliu discovered a pattern: is a small number, and any two update operations are connected. Two update operations are connected if and only if there exist operations such that , , and for , and are mutually exclusive.
A pair of mutually exclusive update operations is called an exclusive pair. Now Duliu wants to know, given and the exclusive pairs, how many different solvable data-structure problems he can set. Two data-structure problems are different if and only if there exists an update operation that appears in one but not in the other.
Input Format
The first line contains positive integers .
The next lines each contain two positive integers , representing a pair of mutually exclusive update operations.
Output Format
Output a single integer on one line, representing the number of solvable different data-structure problems that Duliu can set. This number can be large, so output it modulo .
3 2
1 2
2 3
5
6 8
1 2
1 3
1 4
2 4
3 5
4 5
4 6
1 6
16
12 18
12 6
3 11
8 6
2 9
10 4
1 8
6 2
11 5
10 6
12 2
9 3
7 6
2 7
3 2
7 3
5 6
2 11
12 1
248
Hint
Explanation for Sample 1
The solvable problems include . Note that the empty set is a valid data-structure problem.
Constraints

Translated by ChatGPT 5
京公网安备 11011102002149号