Problem L. Loop nest
时间限制 2000 ms
内存限制 512 MB
There are $m$ sets $P_i,Q_i$,$\forall i(1\leq i\leq m),Pi,Qi\subseteq \{1…i-1\}$. There are nested loops with $m$ layers, and for the $j$th layer, the loop variable is $i_j$, the lower bound equals $\max\{i_k(k\in P_j)\}$(especially, when $P_j$ is empty set, it means the lower bound equals $1$), the upper bound equals $\min\{i_k(k\in Q_j)\}$(especially, when $Q_j$ is empty set, it means the upper bound equals $n$). HazelFan want to know how many times the loop body will be executed, module $p$.
输入数据
输出数据
For each test case:
A single line contains a nonnegative integer, denoting the answer.
样例输入
复制
2
2 10 233
0 0
1 1 0
6 10 987654321
0 0
1 1 0
0 0
1 3 0
0 1 4
1 2 2 1 2
样例输出
$ Mathjax font initiator $