Maximize Minimum Difference
시간 제한4초메모리 제한2048 MB
각 제약 집합마다 인접한 원소 차이의 최솟값을 최대로 만드는 순열 중 주어진 고정 위치를 만족하는 개수를 10^9+7로 나눈 나머지로 센다.
문제
Moo! You are given an integer (). Consider all permutations of . Let denote the minimum absolute difference between any two consecutive elements of . and let denote the set of all that achieve the maximum possible value of .
You are additionally given () constraints of the form (). Count the number of permutations in satisfying all constraints, modulo .
입력
The first line contains () and , meaning that you will need to solve independent test cases, each specified by a different set of constraints.
Each test case starts with , followed by lines each containing and . It is guaranteed that
- The same does not appear more than once within the same test case.
- The same does not appear more than once within the same test case.
출력
For each test case, the answer modulo on a separate line.