

Time Limit: 4 sec / Memory Limit: 1024 MiB
配点 : 1000 点
問題文
maroon くんの夏休みは Day 1 から Day N までの N 日間あります. また夏休み期間中には,1 から M までの番号のついた M 本の映画の上映が予定されており,映画 i は Day L_i から Day R_i まで見られます.
映画全体の部分集合 s に対し,f(s) を以下のように定義します.
- maroon くんが 1 日に 1 本以下の映画を見られるとき,夏休みを通して見られる s 内の映画の本数の最大値を f(s) とする. なお,同じ映画を複数回見てもそれは 1 本とカウントするものとする.
s としてあり得る集合は 2^M 通りあります. それら全てに対する f(s) の総和を 998244353 で割ったあまりを求めてください.
制約
- 1 \leq N \leq 100
- 1 \leq M \leq N \times (N+1) /2
- 1 \leq L_i \leq R_i \leq N
- (L_i,R_i) \neq (L_j,R_j) (i \neq j)
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる.
N M L_1 R_1 L_2 R_2 \vdots L_M R_M
出力
答えを出力せよ.
入力例 1
2 3 1 1 2 2 1 2
出力例 1
11
ほとんどの s に対して,f(s)=|s| が成り立ちます. 唯一の例外は s=\{1,2,3\} で,このとき f(s)=2 となります. すべての s に対する f(s) の総和は 11 です.
入力例 2
3 3 1 1 2 2 3 3
出力例 2
12
入力例 3
4 10 3 3 2 4 2 3 4 4 3 4 1 3 1 1 2 2 1 2 1 4
出力例 3
3796
入力例 4
7 20 1 3 4 5 3 3 3 5 1 4 4 7 2 3 1 7 6 7 4 6 2 4 6 6 3 6 2 5 7 7 3 4 2 2 5 5 2 6 1 2
出力例 4
7113137
Score : 1000 points
Problem Statement
Maroon's summer vacation lasts N days from Day 1 through Day N. During the vacation, M movies numbered from 1 through M are scheduled to be screened, and movie i can be watched from Day L_i through Day R_i.
For a subset s of all movies, define f(s) as follows:
- f(s) is the maximum number of movies in s that can be watched throughout the vacation when he can watch at most one movie per day. Here, watching the same movie multiple times counts as one movie.
There are 2^M possible sets for s. Find the sum, modulo 998244353, of f(s) over all of them.
Constraints
- 1 \leq N \leq 100
- 1 \leq M \leq N \times (N+1) /2
- 1 \leq L_i \leq R_i \leq N
- (L_i,R_i) \neq (L_j,R_j) (i \neq j)
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N M L_1 R_1 L_2 R_2 \vdots L_M R_M
Output
Output the answer.
Sample Input 1
2 3 1 1 2 2 1 2
Sample Output 1
11
f(s)=|s| holds for most s. The only exception is s=\{1,2,3\}, where f(s)=2. The sum of f(s) over all s is 11.
Sample Input 2
3 3 1 1 2 2 3 3
Sample Output 2
12
Sample Input 3
4 10 3 3 2 4 2 3 4 4 3 4 1 3 1 1 2 2 1 2 1 4
Sample Output 3
3796
Sample Input 4
7 20 1 3 4 5 3 3 3 5 1 4 4 7 2 3 1 7 6 7 4 6 2 4 6 6 3 6 2 5 7 7 3 4 2 2 5 5 2 6 1 2
Sample Output 4
7113137