atcoder#AGC060F. [AGC060F] Spanning Trees of Interval Graph
[AGC060F] Spanning Trees of Interval Graph
Score : points
Problem Statement
You have a simple undirected graph. Each vertex in this graph has an integer interval written on it, and there are vertices with the interval (). There are no vertices with other intervals.
For any two vertices, there is an undirected edge between them if and only if the written intervals intersect. Here, an interval and an interval intersect if and only if .
Find the number of spanning trees of this graph, modulo . Here, all vertices are pairwise distinguishable.
Constraints
- All numbers in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
2
1 2
1
8
3
1 1 1
1 1
1
99
4
8 3 8 10
1 5 3
1 6
4
971555314
10
2742 5611 1401 5439 5220 8571 4998 4194 7443 2492
2393 3201 9106 1649 2456 1984 7159 9679 7695
808 4600 2573 7771 5839 9504 4381 3223
5325 2564 456 5050 6963 913 9072
310 1521 9816 6205 2988 3614
4810 2979 2852 9242 6290
7551 7139 7228 699
4869 889 7597
4239 5970
865
234850531