#P5464. 缩小社交圈
缩小社交圈
Problem Description
There are people in a social circle. Each person has a SAN value interval . If the SAN intervals of two people have a non-empty intersection, then these two people have a PY relationship.
Now we want to pick some people from the social circle to form a set . If we add an edge between every pair of people in the set who have a PY relationship, then must form exactly a tree (a forest is not allowed).
How many ways are there to choose such a set? Since the answer may be very large, output it modulo .
Input Format
The first line contains an integer .
The next lines each contain two integers, describing the SAN value interval of a person.
Output Format
Output one integer, the answer.
3
1 5
2 7
4 8
6
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5