#P3295. [SCOI2016] 萌萌哒
[SCOI2016] 萌萌哒
Description
An -digit number is denoted by , where is the -th digit and is the most significant digit. You are given several constraints. Each constraint is given by four integers , meaning two intervals of the same length, and it requires the substrings and to be exactly the same.
For example, when and there is a constraint , then 123123 and 351351 both satisfy the condition, but 12012 and 131141 do not. The former is not of length , and in the latter the second and fifth digits differ. Find how many numbers satisfy all the given conditions.
Input Format
The first line contains two integers and , representing the length of the number and the number of constraints.
Each of the next lines contains four integers on the -th line, representing the two intervals for that constraint.
, , , and it is guaranteed that .
Output Format
Output a single integer, the number of -digit numbers that satisfy all the constraints. Since the answer can be large, output it modulo .
4 2
1 2 3 4
3 3 3 3
90
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号