Problem Statement
Given are an integer N and M pairs of integers. The i-th pair is (Li,Ri).
Find the number of integer sequences x=(x1,x2,cdots,xM) that can be generated as follows, modulo 998244353.
- Provide a permutation p=(p1,p2,cdots,pN) of (1,2,cdots,N).
- For each i (1leqileqM), let xi be the index of the largest element among pLi,pLi+1,cdots,pRi. That is, max(pLi,pLi+1,cdots,pRi)=pxi.
Constraints
- 2leqNleq300
- 1leqMleqN(N−1)/2
- 1leqLi<RileqN
- (Li,Ri)neq(Lj,Rj) (ineqj)
- All values in input are integers.
Input is given from Standard Input in the following format:
N M
L1 R1
L2 R2
vdots
LM RM
Output
Print the answer.
3 2
1 2
1 3
Sample Output 1
4
For example, for p=(2,1,3), we will have x=(1,3).
The four sequences that meet the requirement are x=(1,1),(1,3),(2,2),(2,3).
6 3
1 2
3 4
5 6
Sample Output 2
8
10 10
8 10
5 8
5 7
2 5
1 7
4 5
5 9
2 8
7 8
3 9
Sample Output 3
1060