Polynomial Round 2022 (Div. 1 + Div. 2, Rated, Prizes!)
G
Segment Covering
Codeforces
3200
原题
← F2H →
翻译中…

ChthollyNotaSeniorious gives DataStructures a number axis with $m$ distinct segments on it. Let $f(l,r)$ be the number of ways to choose an even number of segments such that the union of them is exactly $[l,r]$, and $g(l,r)$ be the number of ways to choose an odd number of segments such that the union of them is exactly $[l,r]$.

翻译中…

ChthollyNotaSeniorious asked DataStructures $q$ questions. In each query, ChthollyNotaSeniorious will give DataStructures two numbers $l, r$, and now he wishes that you can help him find the value $f(l,r)-g(l,r)$ modulo $998\,244\,353$ so that he wouldn't let her down.

翻译中…

Input

翻译中…

The first line of input contains two integers $m$ ($1 \leq m \leq 2 \cdot 10^5$) and $q$ ($1 \leq q \leq 2 \cdot 10^5$)  — the number of segments and queries, correspondingly.

翻译中…

The $i$-th of the next $m$ lines contains two integers $x_i$ and $y_i$ ($1 \leq x_i \lt y_i \leq 10^9$), denoting a segment $[x_i, y_i]$.

翻译中…

It is guaranteed that all segments are distinct. More formally, there do not exist two numbers $i, j$ with $1 \le i \lt j \le m$ such that $x_i = x_j$ and $y_i = y_j$.

翻译中…

The $i$-th of the next $q$ lines contains two integers $l_i$ and $r_i$ ($1 \leq l_i \lt r_i \leq 10^9$), describing a query.

翻译中…

Output

翻译中…

For each query, output a single integer  — $f(l_i,r_i)-g(l_i,r_i)$ modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first query, we have to find $f(1, 4) - g(1, 4)$. The only subset of segments with union $[1, 4]$ is $\{[1, 3], [2, 4]\}$, so $f(1, 4) = 1, g(1, 4) = 0$.

翻译中…

In the second query, we have to find $f(1, 5) - g(1, 5)$. The only subsets of segments with union $[1, 5]$ are $\{[1, 3], [2, 4], [3, 5]\}$ and $\{[1, 3], [3, 5]\}$, so $f(1, 5) = 1, g(1, 5) = 1$.

翻译中…

样例

Input #1
4 2
1 3
4 6
2 4
3 5
1 4
1 5
Output #1
1
0
InputCopy OutputCopy
题目信息
题号
1774G
时间限制
2 s
内存限制
256 MB
标签
暴力
组合数学
构造
数据结构
动态规划
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。