Codeforces Round 361 (Div. 2)
E
Mike and Geometry Problem
Codeforces
2000
原题
← D→
翻译中…

Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define $*f*([*l*, *r*]) = *r* - *l* + 1$ to be the number of integer points in the segment $[*l*, *r*]$ with $*l* ≤ *r*$ (say that image). You are given two integers $*n*$ and $*k*$ and $*n*$ closed intervals $[*l*_{*i*}, *r*_{*i*}]$ on $*OX*$ axis and you have to find:

翻译中…

image

翻译中…

In other words, you should find the sum of the number of integer points in the intersection of any $*k*$ of the segments.

翻译中…

As the answer may be very large, output it modulo $1000000007$ ($10^{9} + 7$).

翻译中…

Mike can't solve this problem so he needs your help. You will help him, won't you?

翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*k*$ ($1 ≤ *k* ≤ *n* ≤ 200 000$) — the number of segments and the number of segments in intersection groups respectively.

翻译中…

Then $*n*$ lines follow, the $*i*$-th line contains two integers $*l*_{*i*}, *r*_{*i*}$ $( - 10^{9} ≤ *l*_{*i*} ≤ *r*_{*i*} ≤ 10^{9})$, describing $*i*$-th segment bounds.

翻译中…

Output

翻译中…

Print one integer number — the answer to Mike's problem modulo $1000000007$ ($10^{9} + 7$) in the only line.

翻译中…

Note

翻译中…

In the first example:

翻译中…

image;

翻译中…

image;

翻译中…

image.

翻译中…

So the answer is $2 + 1 + 2 = 5$.

翻译中…

样例

Input #1
3 2
1 2
1 3
2 3
Output #1
5
InputCopy OutputCopy
Input #2
3 3
1 3
1 3
1 3
Output #2
3
InputCopy OutputCopy
Input #3
3 1
1 2
2 3
3 4
Output #3
6
InputCopy OutputCopy
题目信息
题号
689E
时间限制
3 s
内存限制
256 MB
标签
组合数学
数据结构
动态规划
计算几何
模拟

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