Codeforces Round 672 (Div. 2)
D
Rescue Nibel!
Codeforces
1800
原题
← C2E →
翻译中…

Ori and Sein have overcome many difficult challenges. They finally lit the Shrouded Lantern and found Gumon Seal, the key to the Forlorn Ruins. When they tried to open the door to the ruins... nothing happened.

翻译中…

Ori was very surprised, but Sein gave the explanation quickly: clever Gumon decided to make an additional defence for the door.

翻译中…

There are $n$ lamps with Spirit Tree's light. Sein knows the time of turning on and off for the $i$-th lamp — $l_i$ and $r_i$ respectively. To open the door you have to choose $k$ lamps in such a way that there will be a moment of time when they all will be turned on.

翻译中…

While Sein decides which of the $k$ lamps to pick, Ori is interested: how many ways there are to pick such $k$ lamps that the door will open? It may happen that Sein may be wrong and there are no such $k$ lamps. The answer might be large, so print it modulo $998\,244\,353$.

翻译中…

Input

翻译中…

First line contains two integers $n$ and $k$ ($1 \le n \le 3 \cdot 10^5$, $1 \le k \le n$) — total number of lamps and the number of lamps that must be turned on simultaneously.

翻译中…

Next $n$ lines contain two integers $l_i$ ans $r_i$ ($1 \le l_i \le r_i \le 10^9$) — period of time when $i$-th lamp is turned on.

翻译中…

Output

翻译中…

Print one integer — the answer to the task modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In first test case there are nine sets of $k$ lamps: $(1, 2, 3)$, $(1, 2, 4)$, $(1, 2, 5)$, $(1, 2, 6)$, $(1, 3, 6)$, $(1, 4, 6)$, $(2, 3, 6)$, $(2, 4, 6)$, $(2, 6, 7)$.

翻译中…

In second test case $k=1$, so the answer is 3.

翻译中…

In third test case there are no such pairs of lamps.

翻译中…

In forth test case all lamps are turned on in a time $3$, so the answer is 1.

翻译中…

In fifth test case there are seven sets of $k$ lamps: $(1, 2)$, $(1, 3)$, $(2, 3)$, $(2, 4)$, $(3, 4)$, $(3, 5)$, $(4, 5)$.

翻译中…

样例

Input #1
7 3
1 7
3 8
4 5
6 7
1 3
5 10
8 9
Output #1
9
InputCopy OutputCopy
Input #2
3 1
1 1
2 2
3 3
Output #2
3
InputCopy OutputCopy
Input #3
3 2
1 1
2 2
3 3
Output #3
0
InputCopy OutputCopy
Input #4
3 3
1 3
2 3
3 3
Output #4
1
InputCopy OutputCopy
Input #5
5 2
1 3
2 4
3 5
4 6
5 7
Output #5
7
InputCopy OutputCopy
题目信息
题号
1420D
时间限制
2 s
内存限制
256 MB
标签
组合数学
数据结构
排序

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