#P6144. [USACO20FEB] Help Yourself P
[USACO20FEB] Help Yourself P
Problem Description
There are line segments on a number line. The -th segment covers all real numbers from to (including and ).
Define the union of several segments as the set containing all points that are covered by at least one segment.
Define the complexity of several segments as the -th power of the number of connected components in the union of these segments.
Now Bessie wants to compute, among all subsets of the given segments (there are subsets in total), the sum of their complexities modulo .
You might think you need to help Bessie solve this problem. Unfortunately, you guessed wrong! In this problem, you are Bessie, and no one will help you. You are on your own.
Input Format
The first line contains two integers and (; ).
The next lines each contain two integers , describing a segment. It is guaranteed that , and no two endpoints are at the same position.
Output Format
Output the required answer modulo .
3 2
1 6
2 3
4 5
10
Hint
Sample Explanation
The complexities of all non-empty subsets are as follows (clearly, the complexity of the empty set is zero):
$$\{[1,6]\} \implies 1, \{[2,3]\} \implies 1, \{[4,5]\} \implies 1$$$$\{[1,6],[2,3]\} \implies 1, \{[1,6],[4,5]\} \implies 1, \{[2,3],[4,5]\} \implies 4$$Therefore, the answer is .
Subtasks
- Test point satisfies .
- Test points satisfy and .
- Test points satisfy .
- For test point (), .
Translated by ChatGPT 5