문제
Farmer John is hiring a new herd leader for his cows. To that end, he has interviewed () cows for the position. After each interview, he assigned an integer "cowmpetency" score to the candidate ranging from to () that is correlated with their leadership abilities.
Because he has interviewed so many cows, Farmer John has forgotten all of their cowmpetency scores. However, he does remembers () pairs of numbers where cow was the first cow with a strictly greater cowmpetency score than cows through (so ).
Farmer John now tells you the pairs of . Help him count how many sequences of cowmpetency scores are consistent with this information! It is guaranteed that there is at least one such sequence. Because this number may be very large, output its value modulo .
입력
The first line contains , , and .
The next lines each contain a pair . It is guaranteed that all are distinct.
출력
The number of sequences of cowmpetency scores consistent with what Farmer John remembers, modulo .
예제 입력 1
6 2 3
2 3
4 5
예제 출력 1
6
예제 입력 2
10 1 20
1 3
예제 출력 2
399988086
점수
Inputs 3-4 satisfy and .Inputs 5-7 satisfy .Inputs 8-10 satisfy and .Inputs 11-15 satisfy .Inputs 16-20 satisfy no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인