CF1420D.Rescue Nibel!

传统题 时间 2000 ms 内存 256 MiB 9 尝试 3 已通过 1 标签

Rescue Nibel!

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 nn lamps with Spirit Tree's light. Sein knows the time of turning on and off for the ii-th lamp — lil_i and rir_i respectively. To open the door you have to choose kk 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 kk lamps to pick, Ori is interested: how many ways there are to pick such kk lamps that the door will open? It may happen that Sein may be wrong and there are no such kk lamps. The answer might be large, so print it modulo 998244353998\,244\,353.

Input

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

Next nn lines contain two integers lil_i ans rir_i (1liri1091 \le l_i \le r_i \le 10^9) — period of time when ii-th lamp is turned on.

Output

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

Note

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

In second test case k=1k=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 33, so the answer is 1.

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

Samples

7 3
1 7
3 8
4 5
6 7
1 3
5 10
8 9
9
3 1
1 1
2 2
3 3
3
3 2
1 1
2 2
3 3
0
3 3
1 3
2 3
3 3
1
5 2
1 3
2 4
3 5
4 6
5 7
7

在线编程 IDE

建议全屏模式获得最佳体验