#P15770. [JAG 2025 Summer Camp #2] To All Tha Customers
[JAG 2025 Summer Camp #2] To All Tha Customers
题目描述
A shop sells items numbered .
There are people who visit the shop one after another. When person arrives, they first look at which items are currently for sale, and then act as follows:
- They buy item if it is available.
- Otherwise, they buy item if it is available.
- Otherwise, they buy nothing and leave.
Note that it is possible that .
There are possible arrival orders for the people. Compute the number of arrival orders for which every person is able to buy an item. Output that number modulo .
输入格式
$$\begin{aligned} & N \ M \\ & A_1 \ B_1 \\ & A_2 \ B_2 \\ & \vdots \\ & A_M \ B_M \end{aligned} $$The first line contains an integer () representing the number of items sold in the store and () representing the number of people visiting the store.
Each of the following lines contains two integers and ().
输出格式
Print the answer.
4 3
2 1
3 2
3 4
4
6 6
2 3
4 3
5 4
2 5
5 1
6 6
198