#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second

using namespace std;

const int maxn = 200000, mod = trunc(1e9+7);
int n, last, d, k;
typedef pair <int, int> ii;
ii A[2*maxn+1];
ll res, Pow[maxn+1];

ll POW(ll a, int i)
{
    if (!i) return 1;
    if (i == 1) return a;
    int tmp = POW(a, i/2);
    tmp = tmp * tmp % mod;
    if (i & 1) tmp = tmp * a % mod;
    return tmp;
}

ll c(int i, int j)
{
    if (i > j) return 0;
    return Pow[j] * POW(Pow[i] * Pow[j-i] % mod, mod - 2) % mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> n >> k;
    for (int i=1; i<=n; i++)
    {
        int l, r;
        cin >> l >> r;
        A[i].fi = l-1;
        A[i].se = 1;
        A[n+i].fi = r;
        A[n+i].se = -1;
    }
    Pow[0] = 1;
    for (int i=1; i<=n; i++) Pow[i] = Pow[i-1] * i % mod;
    sort(A+1, A+2*n+1);
    for (int i=1; i<=2*n; i++)
    {
        res = (res + 1LL * c(k, d) * (A[i].fi - last) % mod) % mod;
        d += A[i].se;
        last = A[i].fi;
    }
    cout << res;
    return 0;
}


#include<bits/stdc++.h>
#define mod ((ll)(1e9+7))
typedef long long ll;
using namespace std;
vector<pair<ll,int> >v;
ll fac[200001];
ll qpow(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ans;
}
ll C(ll n,ll m)
{
    if(m>n||m<0)
        return 0;
    return (((fac[n]*qpow(fac[m],mod-2))%mod)*qpow(fac[n-m],mod-2))%mod;
}
int main()
{
    int n;
    ll k;
    scanf("%d%I64d",&n,&k);
    fac[0]=1;
    for(ll i=1;i<=n;i++)
        fac[i]=(fac[i-1]*i)%mod;
    for(int i=0;i<n;i++)
    {
        ll l,r;
        scanf("%I64d%I64d",&l,&r);
        v.push_back(make_pair(l-1,1));
        v.push_back(make_pair(r,-1));
    }
    sort(v.begin(),v.end());
    ll ans=0;
    ll cnt=0;
    ll st;
    for(int i=0;i<v.size();i++)
    {
        ans=(ans+C(cnt,k)*(v[i].first-st))%mod;
        st=v[i].first;
        cnt+=v[i].second;
    }
    cout<<ans<<endl;
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
struct line{
	int p;
	bool l;
}LL[400010];
int n, k, top;
ll ans;
bool cmp(const line &a, const line &b)
{
	if(a.p != b.p)
		return a.p < b.p;
	if(a.l != b.l)
		return a.l;
	return 0;
}
ll c(int n, int k)
{
	ll res = 1;
	for(int i = 1; i <= k; i++)
		res = res * (n - i + 1) / i;
	return res;
}
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
		int l, r;
		scanf("%d%d", &l, &r);
		LL[top++] = (line){l, 1};
		LL[top++] = (line){r, 0};
	}
	sort(LL, LL + top, cmp);
	int len = 0;
	int l;
	for(int i = 0; i < top; i++){
		if(LL[i].l){
			len++;
			if(len >= k){
				if(len == k)
					l = LL[i].p;
				else
					if(LL[i].p != l){
						ans += (LL[i].p - l) * c(len - 1, k);
			//			ans %= MOD;
						l = LL[i].p;
					}
			}
		}
		else{
			if(len >= k){
				ans += (LL[i].p - l + 1) * c(len, k);
			//	ans %= MOD;
				len--;
				if(len >= k)
					l = LL[i].p + 1;
			}
		}
	}
	printf("%I64d\n", ans);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
struct line{
	int p;
	bool l;
}LL[400010];
int n, k, top;
ll ans;
ll jc[200010];
ll Pow(ll a, ll p)
{
	ll res = 1, t = a;
	while(p){
		if(p & 1)
			res = (t * res) % MOD;
		t = (t * t) % MOD;
		p >>= 1;
	}
	return res;
}

bool cmp(const line &a, const line &b)
{
	if(a.p != b.p)
		return a.p < b.p;
	if(a.l != b.l)
		return a.l;
	return 0;
}
ll c(int n, int k)
{
	ll res = jc[n];
	res = res * Pow(jc[k], MOD - 2) % MOD;
	res = res * Pow(jc[n - k], MOD - 2) % MOD;
	return res;
}
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	scanf("%d%d", &n, &k);
	jc[0] = 1;
	for(int i = 1; i <= n; i++)
		jc[i] = jc[i - 1] * i % MOD;
	for(int i = 0; i < n; i++){
		int l, r;
		scanf("%d%d", &l, &r);
		LL[top++] = (line){l, 1};
		LL[top++] = (line){r, 0};
	}
	sort(LL, LL + top, cmp);
	int len = 0;
	int l;
	for(int i = 0; i < top; i++){
		if(LL[i].l){
			len++;
			if(len >= k){
				if(len == k)
					l = LL[i].p;
				else
					if(LL[i].p != l){
						ans += (LL[i].p - l) * c(len - 1, k);
						ans %= MOD;
						l = LL[i].p;
					}
			}
		}
		else{
			if(len >= k){
				ans += (LL[i].p - l + 1) * c(len, k);
				ans %= MOD;
				if(len - 1 >= k)
					l = LL[i].p + 1;
			}
			len--;
		}
	}
	printf("%I64d\n", ans);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
struct line{
	int p;
	bool l;
}LL[400010];
int n, k, top;
ll ans;
bool cmp(const line &a, const line &b)
{
	if(a.p != b.p)
		return a.p < b.p;
	if(a.l != b.l)
		return a.l;
	return 0;
}
ll c(int n, int k)
{
	ll res = 1;
	for(int i = 1; i <= k; i++)
		res = res * (n - i + 1) / i;
	return res;
}
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
		int l, r;
		scanf("%d%d", &l, &r);
		LL[top++] = (line){l, 1};
		LL[top++] = (line){r, 0};
	}
	sort(LL, LL + top, cmp);
	int len = 0;
	int l;
	for(int i = 0; i < top; i++){
		if(LL[i].l){
			len++;
			if(len >= k){
				if(len == k)
					l = LL[i].p;
				else
					if(LL[i].p != l){
						ans += (LL[i].p - l) * c(len - 1, k);
						ans %= MOD;
						l = LL[i].p;
					}
			}
		}
		else{
			if(len >= k){
				ans += (LL[i].p - l + 1) * c(len, k);
				ans %= MOD;
				len--;
				if(len >= k)
					l = LL[i].p + 1;
			}
		}
	}
	printf("%I64d\n", ans);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
struct line{
	int p;
	bool l;
}LL[400010];
int n, k, top;
ll ans;
bool cmp(const line &a, const line &b)
{
	if(a.p != b.p)
		return a.p < b.p;
	if(a.l != b.l)
		return a.l;
	return 0;
}
ll c(int n, int k)
{
	ll res = 1;
	for(int i = 1; i <= k; i++)
		res = res * (n - i + 1) / i;
	return res;
}
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
		int l, r;
		scanf("%d%d", &l, &r);
		LL[top++] = (line){l, 1};
		LL[top++] = (line){r, 0};
	}
	sort(LL, LL + top, cmp);
	int len = 0;
	int l;
	for(int i = 0; i < top; i++){
		if(LL[i].l){
			len++;
			if(len >= k){
				if(len == k)
					l = LL[i].p;
				else
					if(LL[i].p != l){
						ans += (LL[i].p - l) * c(len - 1, k);
						ans %= MOD;
						l = LL[i].p;
					}
			}
		}
		else{
			if(len >= k){
				ans += (LL[i].p - l + 1) * c(len, k);
				ans %= MOD;
				if(len - 1 >= k)
					l = LL[i].p + 1;
			}
			len--;
		}
	}
	printf("%I64d\n", ans);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
struct line{
	int p;
	bool l;
}LL[400010];
int n, k, top;
ll ans;
bool cmp(const line &a, const line &b)
{
	if(a.p != b.p)
		return a.p < b.p;
	if(a.l != b.l)
		return a.l;
	return 0;
}
ll c(int n, int k)
{
	ll res = 1;
	for(int i = 1; i <= k; i++)
		res = res * (n - i + 1) / i;
	return res;
}
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
		int l, r;
		scanf("%d%d", &l, &r);
		LL[top++] = (line){l, 1};
		LL[top++] = (line){r, 0};
	}
	sort(LL, LL + top, cmp);
	int len = 0;
	int l;
	for(int i = 0; i < top; i++){
		if(LL[i].l){
			len++;
			if(len >= k){
				if(len == k)
					l = LL[i].p;
				else
					if(LL[i].p != l){
						ans += (LL[i].p - l) * c(len - 1, k);
						ans %= MOD;
						l = LL[i].p;
					}
			}
		}
		else{
			if(len >= k){
				ans += (LL[i].p - l + 1) * c(len, k);
				ans %= MOD;
				len--;
				if(len >= k)
					l = LL[i].p + 1;
			}
			len--;
		}
	}
	printf("%I64d\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXn = 2e5 + 10, MOD = 1e9 + 7;
map<int, long long> mp;
int n, k, hp = 1, ar[MAXn];
vector<long long> vec;
long long ans, fact[MAXn], inv[MAXn];

long long pw(long long a, long long b) {
	long long res = 1;
	while(b) {
		if (b & 1)
			res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

long long comb(int kk, int nn) {
	return (fact[nn] * ((inv[kk] * inv[nn-kk]) % MOD)) % MOD;
}

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;r++;
		vec.push_back(l);
		vec.push_back(r);
		mp[l]++;
		mp[r]--;
	}
	fact[0] = 1;
	inv[0] = 1;
	for (int i = 1; i < MAXn; i++) {
		fact[i] = (fact[i-1] * i) % MOD;
		inv[i] = pw(fact[i], MOD - 2);
	}
	sort(vec.begin(), vec.end());
	vec.resize(distance(vec.begin(), unique(vec.begin(), vec.end())));
	for (int i = 0; i < vec.size(); i++) {
		if (i)
			mp[vec[i]] += mp[vec[i-1]];
		if (i != vec.size() - 1) {
			ans += ((vec[i+1] - vec[i]) * comb(k, mp[vec[i]])) % MOD;
			ans %= MOD;
		}
	}
	cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXn = 2e5 + 10, MOD = 1e9 + 7;
map<int, long long> mp;
int n, k, hp = 1, ar[MAXn];
vector<long long> vec;
long long ans, fact[MAXn], inv[MAXn];

long long pw(long long a, long long b) {
	long long res = 1;
	while(b) {
		if (b & 1)
			res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

long long comb(int kk, int nn) {
	if (kk > nn)
		return 0;
	return (fact[nn] * ((inv[kk] * inv[nn-kk]) % MOD)) % MOD;
}

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;r++;
		vec.push_back(l);
		vec.push_back(r);
		mp[l]++;
		mp[r]--;
	}
	fact[0] = 1;
	inv[0] = 1;
	for (int i = 1; i < MAXn; i++) {
		fact[i] = (fact[i-1] * i) % MOD;
		inv[i] = pw(fact[i], MOD - 2);
	}
	sort(vec.begin(), vec.end());
	vec.resize(distance(vec.begin(), unique(vec.begin(), vec.end())));
	for (int i = 0; i < vec.size(); i++) {
		if (i)
			mp[vec[i]] += mp[vec[i-1]];
		if (i != vec.size() - 1) {
			ans += ((vec[i+1] - vec[i]) * comb(k, mp[vec[i]])) % MOD;
			ans %= MOD;
		}
	}
	cout << ans;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=2e6+500;
const ll inf=1e9+500;
const ll mod=1e9+7;
ll seg[maxn*4];
set<ll> st;
ll a[maxn];
pair<ll,ll> in[maxn];
map<ll,ll> ml;
ll fuc[maxn];
ll rfuc[maxn];

ll entekh(ll n,ll k){
	if(k>n)return 0;
	return (((fuc[n]*rfuc[k])%mod)*rfuc[n-k])%mod;
}
ll poww(ll a,ll b){
	if(b==0){
		return 1;
	}
	ll v=poww(a,b/2);
	if(b&1){
		return (((v*v)%mod)*a)%mod;
	}
	return (v*v)%mod;
}
void update(ll L,ll R,ll node,ll l,ll r){
	if(l<= L && R<=r){
		seg[node]++;
		return ;
	}
	if(r<=L || R<=l){
		return ;
	}
	ll mid=(L+R)/2;
	update(L,mid,2*node,l,r);
	update(mid,R,2*node+1,l,r);
}
ll find_s(ll L,ll R,ll node,ll x){
	if(L+1==R){
		return seg[node];
	}
	ll mid=(L+R)/2;
	if(x<mid){
		return seg[node]+find_s(L,mid,2*node,x);
	}
	return seg[node]+find_s(mid,R,2*node+1,x);
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);

	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		ll l,r;
		cin>>l>>r;
		in[i]=mp(l,r);
		st.insert(l);
		st.insert(l-1);
		st.insert(l+1);
		st.insert(r-1);
		st.insert(r);
		st.insert(r+1);
	}
	fuc[0]=1;
	rfuc[0]=1;
	for(ll i=1;i<maxn;i++){
		fuc[i]=(fuc[i-1]*i)%mod;
		rfuc[i]=poww(fuc[i],mod-2);
	}
	ll m=0;
	ll last=-inf;
	for(set<ll> :: iterator it=st.begin();it!=st.end();it++){
		ll v=(*(it));
		ml[v]=m;
		a[m]=v-last;
	//	cout<<m<<":"<<last<<' '<<v<<"   :::  "<<a[m]<<endl;
		last=v;
		m++;
	}
//	cout<<m<<endl;
	for(ll i=0;i<n;i++){
		ll l=ml[in[i].F];
		ll r=ml[in[i].S];
//		cout<<l<<' '<<r<<endl;
		update(0,m,1,l,r+1);//?
	}
	ll ans=0;
	for(ll i=0;i<m;i++){
		ll v=find_s(0,m,1,i);//?
//		cout<<v<<' '<<entekh(v,k)<<endl;
		ans+=(entekh(v,k)*a[i])%mod;
		ans%=mod;
	}
	cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=2e6+500;
const ll inf=1e9+500;
const ll mod=1e9+7;
ll seg[maxn*4];
set<ll> st;
ll a[maxn];
pair<ll,ll> in[maxn];
map<ll,ll> ml;
ll fuc[maxn];
ll rfuc[maxn];

ll entekh(ll n,ll k){
	if(k>n)return 0;
	return (((fuc[n]*rfuc[k])%mod)*rfuc[n-k])%mod;
}
ll poww(ll a,ll b){
	if(b==0){
		return 1;
	}
	ll v=poww(a,b/2);
	if(b&1){
		return (((v*v)%mod)*a)%mod;
	}
	return (v*v)%mod;
}
void update(ll L,ll R,ll node,ll l,ll r){
	if(l<= L && R<=r){
		seg[node]++;
		return ;
	}
	if(r<=L || R<=l){
		return ;
	}
	ll mid=(L+R)/2;
	update(L,mid,2*node,l,r);
	update(mid,R,2*node+1,l,r);
}
ll find_s(ll L,ll R,ll node,ll x){
	if(L+1==R){
		return seg[node];
	}
	ll mid=(L+R)/2;
	if(x<mid){
		return seg[node]+find_s(L,mid,2*node,x);
	}
	return seg[node]+find_s(mid,R,2*node+1,x);
}
int main(){
	ios_base::synce_with_stdio(0);cin.tie(0)

	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		ll l,r;
		cin>>l>>r;
		in[i]=mp(l,r);
		st.insert(l);
		st.insert(l-1);
		st.insert(l+1);
		st.insert(r-1);
		st.insert(r);
		st.insert(r+1);
	}
	fuc[0]=1;
	rfuc[0]=1;
	for(ll i=1;i<maxn;i++){
		fuc[i]=(fuc[i-1]*i)%mod;
		rfuc[i]=poww(fuc[i],mod-2);
	}
	ll m=0;
	ll last=-inf;
	for(set<ll> :: iterator it=st.begin();it!=st.end();it++){
		ll v=(*(it));
		ml[v]=m;
		a[m]=v-last;
	//	cout<<m<<":"<<last<<' '<<v<<"   :::  "<<a[m]<<endl;
		last=v;
		m++;
	}
//	cout<<m<<endl;
	for(ll i=0;i<n;i++){
		ll l=ml[in[i].F];
		ll r=ml[in[i].S];
//		cout<<l<<' '<<r<<endl;
		update(0,m,1,l,r+1);//?
	}
	ll ans=0;
	for(ll i=0;i<m;i++){
		ll v=find_s(0,m,1,i);//?
		cout<<v<<' '<<entekh(v,k)<<endl;
		ans+=(entekh(v,k)*a[i])%mod;
		ans%=mod;
	}
	cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=2e6+500;
const ll inf=1e9+500;
const ll mod=1e9+7;
ll seg[maxn*4];
set<ll> st;
ll a[maxn];
pair<ll,ll> in[maxn];
map<ll,ll> ml;
ll fuc[maxn];
ll rfuc[maxn];

ll entekh(ll n,ll k){
	if(k>n)return 0;
	return (((fuc[n]*rfuc[k])%mod)*rfuc[n-k])%mod;
}
ll poww(ll a,ll b){
	if(b==0){
		return 1;
	}
	ll v=poww(a,b/2);
	if(b&1){
		return (((v*v)%mod)*a)%mod;
	}
	return (v*v)%mod;
}
void update(ll L,ll R,ll node,ll l,ll r){
	if(l<= L && R<=r){
		seg[node]++;
		return ;
	}
	if(r<=L || R<=l){
		return ;
	}
	ll mid=(L+R)/2;
	update(L,mid,2*node,l,r);
	update(mid,R,2*node+1,l,r);
}
ll find_s(ll L,ll R,ll node,ll x){
	if(L+1==R){
		return seg[node];
	}
	ll mid=(L+R)/2;
	if(x<mid){
		return seg[node]+find_s(L,mid,2*node,x);
	}
	return seg[node]+find_s(mid,R,2*node+1,x);
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);

	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		ll l,r;
		cin>>l>>r;
		in[i]=mp(l,r);
		st.insert(l);
		st.insert(l-1);
		st.insert(l+1);
		st.insert(r-1);
		st.insert(r);
		st.insert(r+1);
	}
	fuc[0]=1;
	rfuc[0]=1;
	for(ll i=1;i<maxn;i++){
		fuc[i]=(fuc[i-1]*i)%mod;
		rfuc[i]=poww(fuc[i],mod-2);
	}
	ll m=0;
	ll last=-inf;
	for(set<ll> :: iterator it=st.begin();it!=st.end();it++){
		ll v=(*(it));
		ml[v]=m;
		a[m]=v-last;
	//	cout<<m<<":"<<last<<' '<<v<<"   :::  "<<a[m]<<endl;
		last=v;
		m++;
	}
//	cout<<m<<endl;
	for(ll i=0;i<n;i++){
		ll l=ml[in[i].F];
		ll r=ml[in[i].S];
//		cout<<l<<' '<<r<<endl;
		update(0,m,1,l,r+1);//?
	}
	ll ans=0;
	for(ll i=0;i<m;i++){
		ll v=find_s(0,m,1,i);//?
		cout<<v<<' '<<entekh(v,k)<<endl;
		ans+=(entekh(v,k)*a[i])%mod;
		ans%=mod;
	}
	cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=2e6+500;
const ll inf=1e9+500;
const ll mod=1e9+7;
ll seg[maxn*4];
set<ll> st;
ll a[maxn];
pair<ll,ll> in[maxn];
map<ll,ll> ml;
ll fuc[maxn];
ll rfuc[maxn];

ll entekh(ll n,ll k){
	if(k>n)return 0;
	return (((fuc[n]*rfuc[k])%mod)*rfuc[n-k])%mod;
}
ll poww(ll a,ll b){
	if(b==0){
		return 1;
	}
	ll v=poww(a,b/2);
	if(b&1){
		return (((v*v)%mod)*a)%mod;
	}
	return (v*v)%mod;
}
void update(ll L,ll R,ll node,ll l,ll r){
	if(l<= L && R<=r){
		seg[node]++;
		return ;
	}
	if(r<=L || R<=l){
		return ;
	}
	ll mid=(L+R)/2;
	update(L,mid,2*node,l,r);
	update(mid,R,2*node+1,l,r);
}
ll find_s(ll L,ll R,ll node,ll x){
	if(L+1==R){
		return seg[node];
	}
	ll mid=(L+R)/2;
	if(x<mid){
		return seg[node]+find_s(L,mid,2*node,x);
	}
	return seg[node]+find_s(mid,R,2*node+1,x);
}
int main(){
	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		ll l,r;
		cin>>l>>r;
		in[i]=mp(l,r);
		st.insert(l);
		st.insert(l-1);
		st.insert(l+1);
		st.insert(r-1);
		st.insert(r);
		st.insert(r+1);
	}
	fuc[0]=1;
	rfuc[0]=1;
	for(ll i=1;i<maxn;i++){
		fuc[i]=(fuc[i-1]*i)%mod;
		rfuc[i]=poww(fuc[i],mod-2);
	}
	ll m=0;
	ll last=-inf;
	for(set<ll> :: iterator it=st.begin();it!=st.end();it++){
		ll v=(*(it));
		ml[v]=m;
		a[m]=v-last;
	//	cout<<m<<":"<<last<<' '<<v<<"   :::  "<<a[m]<<endl;
		last=v;
		m++;
	}
//	cout<<m<<endl;
	for(ll i=0;i<n;i++){
		ll l=ml[in[i].F];
		ll r=ml[in[i].S];
//		cout<<l<<' '<<r<<endl;
		update(0,m,1,l,r+1);//?
	}
	ll ans=0;
	for(ll i=0;i<m;i++){
		ll v=find_s(0,m,1,i);//?
//		cout<<v<<' '<<entekh(v,k)<<endl;
		ans+=(entekh(v,k)*a[i])%mod;
		ans%=mod;
	}
	cout<<ans;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define mp make_pair
#define pb push_back
#define ld long double
#define ss(x) (int) x.size()
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl;
#define ios cin.tie(0); ios_base::sync_with_stdio(0);

using namespace std;
using namespace __gnu_pbds;

// order_by_key
// find_by_order
// tree<int>, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ja;
const int nax = 2e5 + 11, mod = 1e9 + 7;
int n, k;
int l[nax], r[nax];
vector <pair<int, int>> v;
int ans = 0;
int fac[nax];
int odw[nax];
int bilans = 0;

int pt(int a, int b) {
	int r = 1;
	while(b) {
		if(b & 1)
			r = (ll) r * a % mod;
		a = (ll) a * a % mod;
		b /= 2;
	}
	return r;
}

int daj(int a, int b) {
	if(b > a)
		return 0;
	return (ll) fac[a] * odw[b] % mod * odw[a - b] % mod;
}

int main() {

	fac[0] = odw[0] = 1;
	FOR(i, 1, 200000) {
		fac[i] = (ll) fac[i - 1] * i % mod;
		odw[i] = pt(fac[i], mod - 2);
	}

	ios
	cin >> n >> k;
	FOR(i, 1, n) {
		cin >> l[i] >> r[i];
		v.pb(mp(l[i], 1));
		v.pb(mp(r[i] + 1, -1));
	}

	sort(v.begin(), v.end());
	int last = -2e9;

	for(int i = 0; i < ss(v); ++i) {
		int j = i;
		if(last != -2e9) {
			ans = (ans + (ll) (v[i].fi - last - 1) * daj(bilans, k) % mod) % mod;
		}
		bilans += v[i].se;

		while(j + 1 < ss(v) && v[j].fi == v[j + 1].fi) {
			++j;
			bilans += v[j].se;
		}

		i = j;
		ans = (ans + daj(bilans, k)) % mod;
		last = v[i].fi;
	}
	cout << ans;

	return 0;
}


/**/
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compile and get accepted.
 *      ____________
 *     /         __ \
 *    /   __    |  | \
 *   /   |__|   |  |  \
 *  (           |__|   )
 *   \                /
 *    \      ___     /
 *     \____________/
 *
 *
 */
const long long mod = 1000000007;

long long fact[500010],inv[500010];

long long NCR(long long N,long long r){
	if(r > N)
		return 0;
	return (fact[N] * inv[r] % mod) * inv[N-r] % mod;
}

long long pow_mod(long long base,long long power) {
	long long res = 1;
	while(power) {
		if(power&1)
			res = res * base % mod;
		base = base * base % mod;
		power >>= 1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	fact[0] = fact[1] = inv[0] = inv[1] = 1;
	for(int i = 2;i < 500010;i++)
		fact[i] = fact[i-1] * i % mod,inv[i] = pow_mod(fact[i],mod-2);

	int N,K,l,r;
	cin>>N>>K;
	vector<pair<int,int> > ev;
	for(int i = 0;i < N;i++) {
		cin>>l>>r;
		ev.push_back({l,1});
		ev.push_back({r+1,-1});
	}

	sort(ev.begin(),ev.end());

	long long last = INT_MIN;
	long long cur = 0;
	long long res = 0;
	for(int i = 0;i < (int)ev.size();) {
		long long len = ev[i].first - last;
		res = (res + len * NCR(cur,K)) % mod;
//		cerr<<cur<<' '<<len<<' '<<last<<' '<<ev[i].first<<endl;
		int j = i;
		while(j < (int)ev.size() && ev[j].first == ev[i].first) {
			cur += ev[j].second;
			j++;
		}
		last = ev[i].first;
		i = j;
	}

	cout<<res<<'\n';
	return 0;
}
/**/


/**/
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compile and get accepted.
 *      ____________
 *     /            \
 *    /   __     __  \
 *   /   |__|   |__|  \
 *  (                  )
 *   \                /
 *    \     \___/    /
 *     \____________/
 *
 *
 */
const long long mod = 1000000007;

long long fact[500010],inv[500010];

long long NCR(long long N,long long r){
	if(r > N)
		return 0;
	return (fact[N] * inv[r] % mod) * inv[N-r] % mod;
}

long long pow_mod(long long base,long long power) {
	long long res = 1;
	while(power) {
		if(power&1)
			res = res * base % mod;
		base = base * base % mod;
		power >>= 1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	fact[0] = fact[1] = inv[0] = inv[1] = 1;
	for(int i = 2;i < 500010;i++)
		fact[i] = fact[i-1] * i % mod,inv[i] = pow_mod(fact[i],mod-2);

	int N,K,l,r;
	cin>>N>>K;
	vector<pair<int,int> > ev;
	for(int i = 0;i < N;i++) {
		cin>>l>>r;
		ev.push_back({l,1});
		ev.push_back({r+1,-1});
	}

	sort(ev.begin(),ev.end());

	long long last = INT_MIN;
	long long cur = 0;
	long long res = 0;
	for(int i = 0;i < (int)ev.size();) {
		long long len = ev[i].first - last;
		res = (res + len * NCR(cur,K)) % mod;
//		cerr<<cur<<' '<<len<<' '<<last<<' '<<ev[i].first<<endl;
		int j = i;
		while(j < (int)ev.size() && ev[j].first == ev[i].first) {
			cur += ev[j].second;
			j++;
		}
		last = ev[i].first;
		i = j;
	}

	cout<<res<<'\n';
	return 0;
}
/**/


#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
ll f[4000005];
int n,k;
ll mod = 1e9+7;
ll bigmod(ll b,ll p ,ll m)
{
    if(p==0)
        return 1;
    if(p%2 == 0)
    {
        ll temp = bigmod(b,p/2,m);
        return (temp*temp)%m;
    }
    return (bigmod(b,p-1,m)*(b%m))%m;
}
ll InverseEuler(ll n, ll MOD)
{
    return bigmod(n,MOD-2,MOD);
}
ll inv[1000005];
ll c(ll n, ll r, ll MOD)
{
    return (f[n]*((inv[r] * inv[n-r]) % MOD)) % MOD;
}
ii a[300005];
ll pre[4000005];
ll F[4000005];

int main()
{
    f[0] = 1;
    f[1] = 1;
    for(ll i=2;i<200005;i++)
    {
        f[i] = f[i-1]*i;
        f[i]%=mod;
    }
    for(int i=0;i<200005;i++)
    {
        inv[i] = InverseEuler(f[i],mod);
    }
    cin>>n>>k;
    set < int > s;
    for(int i=0;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        a[i] = mp(x,y);
        s.insert(x);
        s.insert(y);
        s.insert(x-1);
        s.insert(y-1);
    }
    int cnt = 1;
    map < int , int > my;
    map < int , int > my2;
    for(auto x : s)
    {
        F[cnt] = x;
        my[x] = cnt;
        cnt++;
    }
    for(int i=0;i<n;i++)
    {
        int L = my[a[i].fr];
        int R = my[a[i].sc];
        pre[L]++;
        pre[R+1]--;
    }
    ll res = 0;
    for(int i=1;i<=cnt;i++)
    {
        pre[i]+=pre[i-1];
        if(pre[i] >= k)
        {
            ll dis = F[i]-F[i-1];
            ll sum = c(pre[i],k,mod);
            res += sum * dis;
            res %=mod;
        }
    }
    cout<<res<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
ll f[4000005];
int n,k;
ll mod = 1e9+7;
ll bigmod(ll b,ll p ,ll m)
{
    if(p==0)
        return 1;
    if(p%2 == 0)
    {
        ll temp = bigmod(b,p/2,m);
        return (temp*temp)%m;
    }
    return (bigmod(b,p-1,m)*(b%m))%m;
}
ll InverseEuler(ll n, ll MOD)
{
    return bigmod(n,MOD-2,MOD);
}
ll c(ll n, ll r, ll MOD)
{

    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
ii a[300005];
ll pre[4000005];
ll F[4000005];
int main()
{
    f[0] = 1;
    f[1] = 1;
    for(ll i=2;i<4000005;i++)
    {
        f[i] = f[i-1]*i;
        f[i]%=mod;
    }
    cin>>n>>k;
    set < int > s;
    for(int i=0;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        a[i] = mp(x,y);
        s.insert(x);
        s.insert(y);
        s.insert(x-1);
        s.insert(y-1);
    }
    int cnt = 1;
    map < int , int > my;
    map < int , int > my2;
    for(auto x : s)
    {
        F[cnt] = x;
        my[x] = cnt;
        cnt++;
    }
    for(int i=0;i<n;i++)
    {
        int L = my[a[i].fr];
        int R = my[a[i].sc];
        pre[L]++;
        pre[R+1]--;
    }
    ll res = 0;
    for(int i=1;i<=cnt;i++)
    {
        pre[i]+=pre[i-1];
        if(pre[i] >= k)
        {
            ll dis = F[i]-F[i-1];
            ll sum = c(pre[i],k,mod);
            res += sum * dis;
            res %=mod;
        }
    }
    cout<<res<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
ll f[4000005];
int n,k;
ll mod = 1e9+7;
ll bigmod(ll b,ll p ,ll m)
{
    if(p==0)
        return 1;
    if(p%2 == 0)
    {
        ll temp = bigmod(b,p/2,m);
        return (temp*temp)%m;
    }
    return (bigmod(b,p-1,m)*(b%m))%m;
}
ll InverseEuler(ll n, ll MOD)
{
    return bigmod(n,MOD-2,MOD);
}
ll c(ll n, ll r, ll MOD)
{

    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
ii a[300005];
ll pre[4000005];
int main()
{
    f[0] = 1;
    f[1] = 1;
    for(ll i=2;i<4000005;i++)
    {
        f[i] = f[i-1]*i;
        f[i]%=mod;
    }
    cin>>n>>k;
    set < int > s;
    for(int i=0;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        a[i] = mp(x,y);
        s.insert(x);
        s.insert(y);
        s.insert(x-1);
        s.insert(y-1);
        s.insert(x+1);
        s.insert(y+1);
    }
    int cnt = 1;
    map < int , int > my;
    map < int , int > my2;
    for(auto x : s)
    {
        my2[cnt] = x;
        my[x] = cnt;
        cnt++;
    }
    for(int i=0;i<n;i++)
    {
        int L = my[a[i].fr];
        int R = my[a[i].sc];
        pre[L]++;
        pre[R+1]--;
    }
    ll res = 0;
    for(int i=1;i<=cnt;i++)
    {
        pre[i]+=pre[i-1];
        if(pre[i] >= k)
        {
            ll dis = my2[i]-my2[i-1];
            ll sum = c(pre[i],k,mod);
            res += sum * dis;
            res %=mod;
        }
    }
    cout<<res<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
ll f[4000005];
int n,k;
ll mod = 1e9+7;
ll bigmod(ll b,ll p ,ll m)
{
    if(p==0)
        return 1;
    if(p%2 == 0)
    {
        ll temp = bigmod(b,p/2,m);
        return (temp*temp)%m;
    }
    return (bigmod(b,p-1,m)*(b%m))%m;
}
ll InverseEuler(ll n, ll MOD)
{
    return bigmod(n,MOD-2,MOD);
}
ll inv[2000005];
ll c(ll n, ll r, ll MOD)
{
    return (f[n]*(inv[r] * inv[n-r]) % MOD) % MOD;
}
ii a[300005];
ll pre[4000005];
ll F[4000005];

int main()
{
    f[0] = 1;
    f[1] = 1;
    for(ll i=2;i<2000005;i++)
    {
        f[i] = f[i-1]*i;
        f[i]%=mod;
    }
    for(int i=0;i<2000005;i++)
    {
        inv[i] = InverseEuler(f[i],mod);
    }
    cin>>n>>k;
    set < int > s;
    for(int i=0;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        a[i] = mp(x,y);
        s.insert(x);
        s.insert(y);
        s.insert(x-1);
        s.insert(y-1);
    }
    int cnt = 1;
    map < int , int > my;
    map < int , int > my2;
    for(auto x : s)
    {
        F[cnt] = x;
        my[x] = cnt;
        cnt++;
    }
    for(int i=0;i<n;i++)
    {
        int L = my[a[i].fr];
        int R = my[a[i].sc];
        pre[L]++;
        pre[R+1]--;
    }
    ll res = 0;
    for(int i=1;i<=cnt;i++)
    {
        pre[i]+=pre[i-1];
        if(pre[i] >= k)
        {
            ll dis = F[i]-F[i-1];
            ll sum = c(pre[i],k,mod);
            res += sum * dis;
            res %=mod;
        }
    }
    cout<<res<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
ll f[4000005];
int n,k;
ll mod = 1e9+7;
ll bigmod(ll b,ll p ,ll m)
{
    if(p==0)
        return 1;
    if(p%2 == 0)
    {
        ll temp = bigmod(b,p/2,m);
        return (temp*temp)%m;
    }
    return (bigmod(b,p-1,m)*(b%m))%m;
}
ll InverseEuler(ll n, ll MOD)
{
    return bigmod(n,MOD-2,MOD);
}
ll inv[1000005];
ll c(ll n, ll r, ll MOD)
{
    return (f[n]*(inv[r] * inv[n-r]) % MOD) % MOD;
}
ii a[300005];
ll pre[4000005];
ll F[4000005];

int main()
{
    f[0] = 1;
    f[1] = 1;
    for(ll i=2;i<200005;i++)
    {
        f[i] = f[i-1]*i;
        f[i]%=mod;
    }
    for(int i=0;i<200005;i++)
    {
        inv[i] = InverseEuler(f[i],mod);
    }
    cin>>n>>k;
    set < int > s;
    for(int i=0;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        a[i] = mp(x,y);
        s.insert(x);
        s.insert(y);
        s.insert(x-1);
        s.insert(y-1);
    }
    int cnt = 1;
    map < int , int > my;
    map < int , int > my2;
    for(auto x : s)
    {
        F[cnt] = x;
        my[x] = cnt;
        cnt++;
    }
    for(int i=0;i<n;i++)
    {
        int L = my[a[i].fr];
        int R = my[a[i].sc];
        pre[L]++;
        pre[R+1]--;
    }
    ll res = 0;
    for(int i=1;i<=cnt;i++)
    {
        pre[i]+=pre[i-1];
        if(pre[i] >= k)
        {
            ll dis = F[i]-F[i-1];
            ll sum = c(pre[i],k,mod);
            res += sum * dis;
            res %=mod;
        }
    }
    cout<<res<<endl;
}


#include <stdio.h>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
const int mod=1e9+7;
int pow(int x, int k)
{
	int ret=1;
	for(;k;k>>=1,x=(ll)x*x%mod) if(k&1) ret=(ll)ret*x%mod;
	return ret;
}
const int N=200050;
int F[N],I[N];
int Calc(int n, int k){ return (ll)F[n]*I[n-k]%mod*I[k]%mod;}
set<int> ord;
vector<pair<int,int> > events;
int main()
{
	int n,k,i,l,r;
	scanf("%i %i",&n,&k);
	F[0]=1;
	for(i=1;i<=n;i++) F[i]=(ll)F[i-1]*i%mod;
	I[n]=pow(F[n],mod-2);
	for(i=n-1;~i;i--) I[i]=(ll)I[i+1]*(i+1)%mod;
	for(i=1;i<=n;i++)
	{
		scanf("%i %i",&l,&r);
		events.pb(mp(l,-i));
		events.pb(mp(r,i));
	}
	sort(events.begin(),events.end());
	int sol=0;
	int last=0,time;
	for(i=0;i<events.size();i++)
	{
		time=events[i].first-last;
		last=events[i].first;
		if(ord.size()>=k)
		{
			sol+=(ll)time*Calc(ord.size(),k)%mod;
			sol%=mod;
		}
		if(events[i].second<0) ord.insert(-events[i].second);
		else ord.erase(events[i].second);
	}
	printf("%i\n",sol);
	return 0;
}


#include <stdio.h>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
const int mod=1e9+7;
int pow(int x, int k)
{
	int ret=1;
	for(;k;k>>=1,x=(ll)x*x%mod) if(k&1) ret=(ll)ret*x%mod;
	return ret;
}
const int N=200050;
int F[N],I[N];
int Calc(int n, int k){ return (ll)F[n]*I[n-k]%mod*I[k]%mod;}
set<int> ord;
vector<pair<int,int> > events;
int main()
{
	int n,k,i,l,r;
	scanf("%i %i",&n,&k);
	F[0]=1;
	for(i=1;i<=n;i++) F[i]=(ll)F[i-1]*i%mod;
	I[n]=pow(F[n],mod-2);
	for(i=n-1;~i;i--) I[i]=(ll)I[i+1]*(i+1)%mod;
	for(i=1;i<=n;i++)
	{
		scanf("%i %i",&l,&r);r++;
		events.pb(mp(l,-i));
		events.pb(mp(r,i));
	}
	sort(events.begin(),events.end());
	int sol=0;
	int last=0,time;
	for(i=0;i<events.size();i++)
	{
		time=events[i].first-last;
		last=events[i].first;
		if(ord.size()>=k)
		{
			sol+=(ll)time*Calc(ord.size(),k)%mod;
			sol%=mod;
		}
		if(events[i].second<0) ord.insert(-events[i].second);
		else ord.erase(events[i].second);
	}
	printf("%i\n",sol);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 4e5 + 7;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll md = 1e9 + 7;

pll a[maxn];
vector<ll> q;

map<ll, int> M;

ll z[maxn];
ll f[maxn];

ll modinv(ll x) {
	ll ex = md - 2, ans = 1;
	while (ex > 0) {
		if (ex & 1) ans = (ans * x)%md;
		ex >>= 1ll;
		x = (x * x)%md;
	}
	return ans;
}

int main() {
	ios :: sync_with_stdio(false); cin.tie(0);

	int n, k; cin >> n >> k;

	f[0] = 1; for (int i = 1; i < maxn; i++) f[i] = (f[i - 1] * i)%md;

	for (int i = 1; i <= n; i++) {
		cin >> a[i].first >> a[i].second; q.push_back(a[i].first); q.push_back(a[i].second);
	}

	sort(q.begin(), q.end()); q.resize(unique(q.begin(), q.end()) - q.begin());

	for (int i = 0; i < q.size(); i++) M[q[i]] = i;

	fill(z, z + maxn, 0);

	for (int i = 1; i <= n ; i++) {
		int l = M[a[i].first], r = M[a[i].second];

		//cout << l << " .. " << r << endl;

		z[l]++; z[r + 1]--;
	}

	ll sum = 0, answer = 0;

	q.push_back( q[ q.size() - 1] + 1 );

	for (int i = 0; i < q.size(); i++) {
		sum += z[i];
		ll len = q[i + 1] - q[i];

		//cout << sum << " : " << len << endl;

		if (sum < k) continue;
		ll c = (f[sum] * modinv(f[sum - k]))%md;
		c = (c * modinv(f[k]))%md;

		answer = (answer + c * len)%md;
	}

	cout << answer << endl;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 4e5 + 7;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll md = 1e9 + 7;
const ll inf = 1e9 + 7;

pll a[maxn];

ll f[maxn];
ll g[maxn];

ll modinv(ll x) {
	ll ex = md - 2, ans = 1;
	while (ex > 0) {
		if (ex & 1) ans = (ans * x)%md;
		ex >>= 1ll;
		x = (x * x)%md;
	}
	return ans;
}

typedef struct node {
	int laz;

	node *lft, *rgt;

	node(int _laz) {
		laz = _laz;
		lft = nullptr; rgt = nullptr;
	}

} node;

node* root; int k;

void push(node* z) {
	if (!z -> lft) { z -> lft = new node(0); }
	if (!z -> rgt) { z -> rgt = new node(0); }

	z -> lft -> laz += z -> laz; z -> rgt -> laz += z -> laz; z -> laz = 0;
}

void upd(node* z, int l, int r, int i, int j) {
	if (j < l || r < i) return;
	if (i <= l && r <= j) { z -> laz++; return; }

	push(z); int mid = (l + r) >> 1;

	upd(z -> lft, l, mid, i, j); upd(z -> rgt, mid + 1, r, i, j);
}

ll solve(node* z, int l, int r) {
	if (z -> lft || z -> rgt) {
		push(z); int mid = (l + r) >> 1;
		return (solve(z -> lft, l, mid) + solve(z -> rgt, mid + 1, r))%md;
	}

	ll s = z -> laz;

	if (s < k) return 0;

	//cout << l << " : " << r << " ,, " << s << endl;

	ll c =  ( ((f[s] * g[k])%md) * g[s - k] )%md;

	return (c * (r - l + 1))%md;
}

int main() {
	ios :: sync_with_stdio(false); cin.tie(0);

	root = new node(0);

	int n; cin >> n >> k;

	f[0] = 1; for (int i = 1; i < maxn; i++) f[i] = (f[i - 1] * i)%md;
	g[0] = 1; for (int i = 1; i < maxn; i++) g[i] = modinv(f[i]);

	for (int i = 1; i <= n; i++) {
		int l, r; cin >> l >> r;
		upd(root, -inf, inf, l, r);
	}

	cout << solve(root, -inf, inf) << endl;
}


#include <bits/stdc++.h>
#define PII pair<int,int>
#define LL long long
#define F first
#define S second
using namespace std;
map<int,bool> kt;
map<int,int> f;
vector<int> a;
const int N=200001;
const int mod=1e9+7;
int n,k,gt[N],d[N];
int power(int a,int b)
{
    int res=1;
    for (int i=0;i<=30;i++)
    {
        if ((b>>i)&1) res=(LL)res*a%mod;
        a=(LL)a*a%mod;
    }
    return res;
}
LL cal(int i,int j)
{
    if (i>j) return 0;
    return ((LL)gt[j]*d[i]%mod)*d[j-i]%mod;
}
int main()
{

    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    cin>>n>>k;
    gt[0]=1;
    for (int i=1;i<=n;i++) gt[i]=(LL)gt[i-1]*i%mod;
    for (int i=0;i<=n;i++) d[i]=power(gt[i],mod-2);
    for (int i=1;i<=n;i++)
    {
        int l,r;
        cin>>l>>r;
        r++;
        if (!kt[l]) kt[l]=1,a.push_back(l);
        if (!kt[r]) kt[r]=1,a.push_back(r);
        f[l]++;
        f[r]--;
    }
    int s=0,res=0;
    sort(a.begin(),a.end());
    for (int i=0;i<a.size();i++)
    {
        if (i>0) res+=cal(k,s)*(a[i]-a[i-1])%mod;
        res%=mod;
        s+=f[a[i]];
    }
    cout<<res;
    return 0;
}


#include <bits/stdc++.h> // PLEASE

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 200005
#define MAXM 1005
#define MAXP 31
#define MOD 1000000007
#define INF 2000000000
#define HAX 10000000
#define A first
#define B second
#define MP make_pair
#define PB push_back
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define re(i, n) FOR(i, 1, n)
#define rep(i, n) for(int i = 0; i<(n); ++i)
#define fore(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
int N, K;
map <int, int> cnt;
ll p[MAXP];
ll fac[MAXN];
inline ll mmul(ll a, ll b)
{
	return (a*b)%MOD;
}

inline ll madd(ll a, ll b)
{
	return (a+b)%MOD;
}

ll powmod(ll a, ll b) {
	if(b == 0) return 1LL;
	p[0] = a;
	for(ll i=1; i<MAXP; i++) p[i] = mmul(p[i-1], p[i-1]);
	ll ans = 1;
	for(ll i=MAXP-1; i>=0; i--) {
		if((b-(ll)(1<<i)) >= 0) {
			b = b-(ll)(1<<i);
			ans = mmul(ans, p[i]);
		}
	}
	return ans;
}

inline ll inv(ll a)
{
	return powmod(a, MOD-2);
}

inline ll nck(ll n, ll k)
{
	if(n<k) return 0;
	ll ans = fac[n];
	ans = mmul(ans, inv(fac[k]));
	ans = mmul(ans, inv(fac[n-k]));
	//printf("%lld %lld %lld lol \n", n, k, ans);
	return ans;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K;
	fac[0] = 1;
	for(ll i=1; i<=N; i++) fac[i] = mmul(fac[i-1], i);
	for(int i=0; i<N; i++) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b+1]--;
	}
	int sm = 0;
	for(map <int, int> :: iterator it = cnt.begin(); it != cnt.end(); ++it) {
		sm += (*it).B;
		(*it).B = sm;
	}
	ll ans = 0;
	ll cur = (ll)(*cnt.begin()).A;
	ll x = (ll)(*cnt.begin()).B;
	map <int, int> :: iterator it = cnt.begin();
	++it;
	for(; it != cnt.end(); ++it) {
		ll rt = (ll)(*it).A;
		ll df = rt-cur;
		cur = rt;
	///	cout << df << ' ' << x << ' ' << nck(x, K) << endl;
		ans += mmul(df, nck(x, K));
	//	cout << ans << endl;
		x = (ll)(*it).B;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h> // PLEASE

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 200005
#define MAXM 1005
#define MAXP 31
#define MOD 1000000007
#define INF 2000000000
#define HAX 10000000
#define A first
#define B second
#define MP make_pair
#define PB push_back
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define re(i, n) FOR(i, 1, n)
#define rep(i, n) for(int i = 0; i<(n); ++i)
#define fore(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
int N, K;
map <int, int> cnt;
ll p[MAXP];
ll fac[MAXN];
inline ll mmul(ll a, ll b)
{
	return (a*b)%MOD;
}

inline ll madd(ll a, ll b)
{
	return (a+b)%MOD;
}

ll powmod(ll a, ll b) {
	if(b == 0) return 1LL;
	p[0] = a;
	for(ll i=1; i<MAXP; i++) p[i] = mmul(p[i-1], p[i-1]);
	ll ans = 1;
	for(ll i=MAXP-1; i>=0; i--) {
		if((b-(ll)(1<<i)) >= 0) {
			b = b-(ll)(1<<i);
			ans = mmul(ans, p[i]);
		}
	}
	return ans;
}

inline ll inv(ll a)
{
	return powmod(a, MOD-2);
}

inline ll nck(ll n, ll k)
{
	if(n<k) return 0;
	ll ans = fac[n];
	ans = mmul(ans, inv(fac[k]));
	ans = mmul(ans, inv(fac[n-k]));
	//printf("%lld %lld %lld lol \n", n, k, ans);
	return ans;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K;
	fac[0] = 1;
	for(ll i=1; i<=N; i++) fac[i] = mmul(fac[i-1], i);
	for(int i=0; i<N; i++) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b+1]--;
	}
	int sm = 0;
	for(map <int, int> :: iterator it = cnt.begin(); it != cnt.end(); ++it) {
		sm += (*it).B;
		(*it).B = sm;
	}
	ll ans = 0;
	ll cur = (ll)(*cnt.begin()).A;
	ll x = (ll)(*cnt.begin()).B;
	map <int, int> :: iterator it = cnt.begin();
	++it;
	for(; it != cnt.end(); ++it) {
		ll rt = (ll)(*it).A;
		ll df = rt-cur;
		cur = rt;
	///	cout << df << ' ' << x << ' ' << nck(x, K) << endl;
		ans = madd(ans, mmul(df, nck(x, K)));
	//	cout << ans << endl;
		x = (ll)(*it).B;
	}
	cout << ans << endl;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
// head
const int N = 2e5+5;
const int MOD = 1e9+7;

int l[N], r[N];
int sum[N*2];
int disc[N*2];
int fac[N];
int n, k;

LL powmod(LL a,LL b) {LL res=1;a%=MOD;for(; b; b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
LL inverse(LL a) {return powmod(a, MOD-2);}

int C(int n, int m) {
    if (n < m) return 0;
    return (LL)fac[n] * inverse(fac[m]) % MOD * inverse(fac[n-m]) % MOD;
}

int main() {
    fac[0] = 1;
    for (int i = 1; i < N; i++) {
        fac[i] = ((LL)fac[i-1] * i) % MOD;
    }

    while (scanf("%d%d", &n, &k) == 2) {
        int tot = 0;
        for (int i = 0; i < n; i++) {
            scanf("%d%d", l+i, r+i);
            disc[tot++] = l[i];
            disc[tot++] = ++r[i];
        }
        sort(disc, disc + tot);
        tot = unique(disc, disc + tot) - disc;

        for (int i = 0; i < n; i++) {
            int l = lower_bound(disc, disc + tot, ::l[i]) - disc;
            int r = lower_bound(disc, disc + tot, ::r[i]) - disc;
            sum[l]++;
            sum[r]--;
        }

        int ans = 0;
        for (int i = 1; i < tot; i++) {
            sum[i] += sum[i-1];
            ans = (ans + (LL)C(sum[i-1], k) * (disc[i] - disc[i-1])) % MOD;
        }
        printf("%d\n", ans);
        memset(sum, 0, sizeof sum);
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
const long long mod = 1e9 + 7;
map<int, int>ma;
vector<int> node;
int n, k;
long long zuhe[200010];
int li[200010], ri[200010];
int disc[200010];
long long sum[600010];

long long q_pow(long long p, long long q)
{
	long long cnt = 1;
	long long temp = p;
	while (q > 0)
	{
		if (q % 2 == 1) cnt = (cnt*temp) % mod;
		temp = (temp*temp) % 2;
		q /= 2;
	}
	return cnt;
}

void init()
{
	int i;
	memset(zuhe, 0, sizeof(zuhe));
	zuhe[k] = 1;
	for (i = k + 1; i <= n; i++)
	{
		long long temp = q_pow(i - k, mod - 2);
		zuhe[i] = ((zuhe[i - 1] * i) % mod*temp) % mod;
	}
}

int main()
{
	int i, j;
	scanf("%d%d", &n, &k);
	init();
	int tot = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &li[i], &ri[i]);
		disc[tot++] = li[i];
		disc[tot++] = ++ri[i];
	}
	sort(disc, disc + tot);
	tot = unique(disc, disc + tot) - disc;

	for (int i = 0; i < n; i++) {
		int l = lower_bound(disc, disc + tot, li[i]) - disc;
		int r = lower_bound(disc, disc + tot, ri[i]) - disc;
		sum[l]++;
		sum[r]--;
	}

	long long ans = 0;
	for (int i = 1; i < tot; i++) {
		sum[i] += sum[i - 1];
		if(sum[i-1]>=k)
		   ans = (ans + (long long)zuhe[sum[i-1]] * (disc[i] - disc[i - 1])) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
const long long mod = 1e9 + 7;
map<int, int>ma;
vector<int> node;
int n, k;
long long zuhe[200010];
int li[200010], ri[200010];
int disc[200010];
long long sum[600010];

long long q_pow(long long p, long long q)
{
	long long cnt = 1;
	long long temp = p;
	while (q > 0)
	{
		if (q % 2 == 1) cnt = (cnt*temp) % mod;
		temp = (temp*temp) % 2;
		q /= 2;
	}
	return cnt;
}

void init()
{
	int i;
	memset(zuhe, 0, sizeof(zuhe));
	zuhe[k] = 1;
	for (i = k + 1; i <= n; i++)
	{
		long long temp = q_pow(i - k, mod - 2);
		zuhe[i] = ((zuhe[i - 1] * i) % mod*temp) % mod;
	}
}

int main()
{
	int i, j;
	scanf("%d%d", &n, &k);
	init();
	int tot = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &li[i], &ri[i]);
		disc[tot++] = li[i];
		disc[tot++] = ++ri[i];
	}
	sort(disc, disc + tot);
	tot = unique(disc, disc + tot) - disc;

	for (int i = 0; i < n; i++) {
		int l = lower_bound(disc, disc + tot, li[i]) - disc;
		int r = lower_bound(disc, disc + tot, ri[i]) - disc;
		sum[l]++;
		sum[r]--;
	}

	long long ans = 0;
	for (int i = 1; i < tot; i++) {
		sum[i] += sum[i - 1];
		if(sum[i-1]>=k)
		   ans = (ans + (long long)zuhe[sum[i-1]] * (disc[i] - disc[i - 1])) % mod;
	}
	printf("%d\n", ans);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
const long long mod = 1e9 + 7;
map<int, int>ma;
vector<int> node;
int n, k;
long long zuhe[200010];
int li[200010], ri[200010];
int disc[200010];
long long sum[600010];

long long q_pow(long long p, long long q)
{
	long long cnt = 1;
	long long temp = p;
	while (q > 0)
	{
		if (q % 2 == 1) cnt = (cnt*temp) % mod;
		temp = (temp*temp) % 2;
		q /= 2;
	}
	return cnt;
}

void init()
{
	int i;
	memset(zuhe, 0, sizeof(zuhe));
	zuhe[k] = 1;
	for (i = k + 1; i <= n; i++)
	{
		long long temp = q_pow(i - k, mod - 2);
		zuhe[i] = ((zuhe[i - 1] * i) % mod*temp) % mod;
	}
}

int main()
{
	int i, j;
	scanf("%d%d", &n, &k);
	init();
	int tot = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &li[i], &ri[i]);
		disc[tot++] = li[i];
		disc[tot++] = ++ri[i];
	}
	sort(disc, disc + tot);
	tot = unique(disc, disc + tot) - disc;

	for (int i = 0; i < n; i++) {
		int l = lower_bound(disc, disc + tot, li[i]) - disc;
		int r = lower_bound(disc, disc + tot, ri[i]) - disc;
		sum[l]++;
		sum[r]--;
	}

	long long ans = 0;
	for (int i = 1; i < tot; i++) {
		sum[i] += sum[i - 1];
		if (sum[i - 1] >= k)
			ans = (ans + (zuhe[sum[i - 1]] * (long long)(disc[i] - disc[i - 1])) % mod) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//TO_STRING
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(char ch){
  string s;
  s += ch;
  return s;
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
    to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
    to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//DEBUG
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL //compile with -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<char> vch;
typedef vector<string> vstr;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;
typedef vector<vch> vvch;
typedef vector<vstr> vvstr;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz(x) ((ll)x.size())

const ll mod = 1e9 + 7;

const int maxn = 2e5 + 5;

vll fac(maxn), invfac(maxn);

ll expmod(ll x, ll n, ll mod){
	//x ^ n % mod
	if(n == 0) return 1;
	else if(n % 2 == 0){
		ll temp = expmod(x, n / 2, mod);
		return (temp * temp) % mod;
	}
	else{
		return (expmod(x, n - 1, mod) * x) % mod;
	}
}

ll modinv(ll x, ll mod) {
	return expmod(x, mod - 2, mod);
}

void find_fac() {
	fac[0] = 1;
	invfac[0] = 1;

	for (int i = 1; i < maxn; i++) {
		fac[i] = fac[i - 1] * i % mod;
		invfac[i] = invfac[i - 1] * modinv(i, mod) % mod;
	}
}

ll C(int n, int k) {
	if (k > n) return 0;
	else {
		return fac[n] * invfac[k] % mod * invfac[n - k] % mod;
	}
}

struct Fenwick
{
	int n;
	vi a, t;

	Fenwick(int n): n(n) {
		a.resize(n+1);
		t.resize(n+1);
		a[0] = 0;
		t[0] = 0;
	}

	void update(int pos, int val) {
		for (int x = pos; x <= n; x += x & -x) {
			t[x] += val;
		}
		a[pos] += val;
	}

	int get(int pos) {
		int res = 0;
		for (int x = pos; x >= 1; x-= x & -x) {
			res += t[x];
		}
		return res;
	}

	ll query(int pos, int k, ll mult) {
		int m = get(n) - get(pos - 1);
		ll ans = 0;
		if (m >= k) {
			ans = mult % mod * C(m, k) % mod;
		}
		debug(pos, m, ans);
		return ans;
	}
};

void solve() {
	find_fac();

  int n, k;
  cin >> n >> k;
  vi points;
  vpi segs;
  for (int i = 0; i < n; i++) {
  	int l, r;
  	cin >> l >> r;
  	points.pb(l);
  	points.pb(r);
  	segs.pb({l, r});
  }

  sort(all(points));
 	points.resize(unique(all(points)) - points.begin());

 	map<int, int> id;
 	for (int i = 0; i < sz(points); i++) {
 		id[points[i]] = i + 1;
 	}
  sort(all(segs));

  Fenwick fen(sz(points) + 1);
  int it1 = 0, it2 = 0;

  ll ans = 0;
  while (it1 < sz(points)) {
  	while (it2 < n && segs[it2].fi <= points[it1]) {
  		fen.update(id[segs[it2].se], 1);
  		it2++;
  	}
  	debug("point", points[it1], ans);
  	debug(fen.a);
  	ans += fen.query(id[points[it1]], k, 1);
  	debug("after", ans);

  	if (ans > mod) ans -= mod;
  	if (it1 + 1 < sz(points)) {
  		int l = points[it1];
  		int r = points[it1 + 1];
  		if (r - l - 1 >= 1) {
  			debug("range", l, r, ans);
  			ans += fen.query(id[r], k, r - l - 1);
  			debug("after", ans);
  			if (ans > mod) ans -= mod;
  		}
  	}
  	it1++;
  }
  cout << ans << "\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int t = 1;

  // cin >> t;

  for (int tc = 1; tc <= t; tc++) {
  	solve();
  }
}


#include<cstdio>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<algorithm>
#define lc(x) x<<1
#define rc(x) x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define base 19260817
#define PI acos(-1.0)
using namespace std;

const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
int pos[maxn << 1];
map<int, int> cnt, cover;

ll quickpow(ll a, ll x)
{
	ll res = 1;
	while (x)
	{
		if (x & 1) res = (res*a) % mod;
		a = (a*a) % mod;
		x >>= 1;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		int l, r; cin >> l >> r;
		pos[i] = l, pos[i + n] = r + 1;
		cnt[l]++, cnt[r + 1]--;
	}
	sort(pos + 1, pos + 2 * n + 1);
	int tot = unique(pos + 1, pos + 2 * n + 1) - pos - 1;
	int sum = 0, last = -1;
	for (int i = 1; i <= tot; i++)
	{
		if (last != -1) cover[sum] += pos[i] - last;
		last = pos[i];
		sum += cnt[pos[i]];
	}
	ll ans = 0, comb = 1;
	for (int i = k; i <= n; i++)
	{
		ans = (ans + comb*cover[i] % mod) % mod;
		comb = comb*(i + 1) % mod*quickpow(i + 1 - k, mod - 2) % mod;
	}
	cout << ans;
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long int
struct node
{
    LL x,y;
}a[250000];
const LL mod = 1000000007;
const LL N = 300000+5;
const LL M = 3e5+3;
LL b[5000000];
LL fac[1000005];            //阶乘
LL inv_of_fac[1000005];        //阶乘的逆元
LL qpow(LL x,LL n)
{
    LL ret=1;
    for(; n; n>>=1)
    {
        if(n&1) ret=ret*x%mod;
        x=x*x%mod;
    }
    return ret;
}
void init()
{
    fac[1]=1;
    for(LL i=2; i<=M; i++)
        fac[i]=fac[i-1]*i%mod;
    inv_of_fac[M]=qpow(fac[M],mod-2);
    for(LL i=M-1; i>=0; i--)
        inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod;
}
LL C(LL a,LL b)
{
    if(b>a) return 0;
    if(b==0) return 1;
    return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod;
}
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
LL tree[2000000];
LL flag[2000000];
void pushdown(LL l,LL r,LL rt)//向下维护树内数据
{
    if(flag[rt])//如果贪婪标记不是0（说明需要向下进行覆盖区间（或点）的值）
    {
        LL m=(l+r)/2;
        flag[rt*2]+=flag[rt];
        flag[rt*2+1]+=flag[rt];
        tree[rt*2]+=(m-l+1)*flag[rt];//千万理解如何覆盖的区间值（对应线段树的图片理解（m-l）+1）是什么意识.
        tree[rt*2+1]+=(r-(m+1)+1)*flag[rt];
        flag[rt]=0;
    }
}
void pushup(LL rt)
{
    tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build( LL l ,LL r , LL rt )
{
    if( l == r )
    {
        tree[rt]=0;
        flag[rt]=0;
        return ;
    }
    else
    {
        LL m = (l+r)>>1 ;
        build(lson) ;
        build(rson) ;
        pushup(rt) ;
    }
}
void update(LL L,LL R,LL c,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)//覆盖的是区间~
    {
        tree[rt]+=c*((r-l)+1);//覆盖当前点的值
        flag[rt]+=c;//同时懒惰标记~！
        return ;
    }
    else
    {
        pushdown(l,r,rt);
        LL m=(l+r)/2;
        if(L<=m)
        {
            update(L,R,c,lson);
        }
        if(m<R)
        {
            update(L,R,c,rson);
        }
        pushup(rt);
    }
}
LL  Query(LL L,LL R,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)
    {
        return tree[rt];
    }
    pushdown(l,r,rt);
    LL m=(l+r)>>1;
    LL  ans=0;
    if(L<=m)
    {
        ans+=Query(L,R,lson);
    }
    if(m<R)
    {
        ans+=Query(L,R,rson);
    }
    return ans;
}
int main()
{
    init();
    LL n,k;
    while(~scanf("%I64d%I64d",&n,&k))
    {
        LL cnt=0;
        map<LL ,LL >s;
        map<LL ,LL >rs;
        memset(tree,0,sizeof(tree));
        memset(flag,0,sizeof(flag));
        for(LL i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&a[i].x,&a[i].y);
            b[cnt++]=a[i].x;b[cnt++]=a[i].y;
        }
        LL tot=0;sort(b,b+cnt);
        for(LL i=0;i<cnt;i++)if(s[b[i]]==0)s[b[i]]=++tot,rs[tot]=b[i];
        rs[tot+1]=b[cnt-1]+1;
        build(1,tot,1);
        for(LL i=0;i<n;i++)
        {
            update(s[a[i].x],s[a[i].y],1,1,tot,1);
        }
        LL output=0;
        /*
        for(int i=1;i<=tot;i++)
        {
            printf("%I64d ",Query(i,i,1,tot,1));
        }
        printf("\n");*/
        for(int i=1;i<=tot;i++)
        {
            if(rs[i+1]-rs[i]==1)
            {
                output+=C(Query(i,i,1,tot,1),k);
              //  printf("%I64d\n",output);
                continue;
            }
            output+=min(C(Query(i,i,1,tot,1),k),C(Query(i+1,i+1,1,tot,1),k))*(rs[i+1]-rs[i]);
            if(Query(i,i,1,tot,1)>Query(i+1,i+1,1,tot,1))output+=C(Query(i,i,1,tot,1),k);
          //  printf("%I64d\n",output);
            output%=mod;
        }
        printf("%I64d\n",output);
    }
}


#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long int
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
struct node
{
    LL x,y;
}a[250000];
LL vis[2000000];
LL tree[2000000];
LL flag[2000000];
const LL mod = 1000000007;
const LL N = 300000+5;
const LL M = 3e5+3;
LL b[5000000];
LL fac[1000005];            //阶乘
LL inv_of_fac[1000005];        //阶乘的逆元
LL qpow(LL x,LL n)
{
    LL ret=1;
    for(; n; n>>=1)
    {
        if(n&1) ret=ret*x%mod;
        x=x*x%mod;
    }
    return ret;
}
void init()
{
    fac[1]=1;
    for(LL i=2; i<=M; i++)
        fac[i]=fac[i-1]*i%mod;
    inv_of_fac[M]=qpow(fac[M],mod-2);
    for(LL i=M-1; i>=0; i--)
        inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod;
}
LL C(LL a,LL b)
{
    if(b>a) return 0;
    if(b==0) return 1;
    return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod;
}
void pushdown(LL l,LL r,LL rt)//向下维护树内数据
{
    if(flag[rt])//如果贪婪标记不是0（说明需要向下进行覆盖区间（或点）的值）
    {
        LL m=(l+r)/2;
        flag[rt*2]+=flag[rt];
        flag[rt*2+1]+=flag[rt];
        tree[rt*2]+=(m-l+1)*flag[rt];//千万理解如何覆盖的区间值（对应线段树的图片理解（m-l）+1）是什么意识.
        tree[rt*2+1]+=(r-(m+1)+1)*flag[rt];
        flag[rt]=0;
    }
}
void pushup(LL rt)
{
    tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build( LL l ,LL r , LL rt )
{
    if( l == r )
    {
        tree[rt]=0;
        flag[rt]=0;
        return ;
    }
    else
    {
        LL m = (l+r)>>1 ;
        build(lson) ;
        build(rson) ;
        pushup(rt) ;
    }
}
void update(LL L,LL R,LL c,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)//覆盖的是区间~
    {
        tree[rt]+=c*((r-l)+1);//覆盖当前点的值
        flag[rt]+=c;//同时懒惰标记~！
        return ;
    }
    else
    {
        pushdown(l,r,rt);
        LL m=(l+r)/2;
        if(L<=m)
        {
            update(L,R,c,lson);
        }
        if(m<R)
        {
            update(L,R,c,rson);
        }
        pushup(rt);
    }
}
LL  Query(LL L,LL R,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)
    {
        return tree[rt];
    }
    pushdown(l,r,rt);
    LL m=(l+r)>>1;
    LL  ans=0;
    if(L<=m)
    {
        ans+=Query(L,R,lson);
    }
    if(m<R)
    {
        ans+=Query(L,R,rson);
    }
    return ans;
}
int main()
{
    init();
    LL n,k;
    while(~scanf("%I64d%I64d",&n,&k))
    {
        LL cnt=0;
        map<LL ,LL >s;
        map<LL ,LL >rs;
        memset(vis,0,sizeof(vis));
        memset(tree,0,sizeof(tree));
        memset(flag,0,sizeof(flag));
        for(LL i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&a[i].x,&a[i].y);
            b[cnt++]=a[i].x;b[cnt++]=a[i].y;
        }
        LL tot=0;sort(b,b+cnt);
        for(LL i=0;i<cnt;i++)if(s[b[i]]==0)s[b[i]]=++tot,rs[tot]=b[i];
        rs[tot+1]=b[cnt-1]+1;
        build(1,tot,1);
        for(LL i=0;i<n;i++)
        {
            if(a[i].x==a[i].y)while(1);
            update(s[a[i].x],s[a[i].y],1,1,tot,1);
        }
        LL output=0;
        /*
        for(int i=1;i<=tot;i++)
        {
            printf("%I64d ",Query(i,i,1,tot,1));
        }
        printf("\n");*/
        for(int i=1;i<=tot;i++)
        {
            if(rs[i+1]-rs[i]==1)
            {
                vis[i]=1;
                output+=C(Query(i,i,1,tot,1),k);
                output%=mod;
                continue;
            }
            if(Query(i,i,1,tot,1)<=Query(i+1,i+1,1,tot,1))
            {
                output+=C(Query(i,i,1,tot,1),k)*(rs[i+1]-rs[i]);
                if(vis[i]==1)output-=C(Query(i,i,1,tot,1),k);
                vis[i]=1;
            }
            else
            {
                output+=C(Query(i+1,i+1,1,tot,1),k)*(rs[i+1]-rs[i]);
                vis[i+1]=1;
                if(vis[i]==0)output+=C(Query(i,i,1,tot,1),k);
                vis[i]=1;
            }
            output%=mod;
        }
        printf("%I64d\n",output);
      //  printf("%I64d\n",output);
    }
}


#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long int
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
const LL mod = 1000000007;
const LL N = 500000+5;
const LL M = 5e5+3;
struct node
{
    LL x,y;
}a[250000];
LL vis[3000000];
LL tree[3000000];
LL flag[3000000];
LL q[3000000];
LL b[5000000];
LL fac[3000005];            //阶乘
LL inv_of_fac[3000005];        //阶乘的逆元
LL qpow(LL x,LL n)
{
    LL ret=1;
    for(; n; n>>=1)
    {
        if(n&1) ret=ret*x%mod;
        x=x*x%mod;
    }
    return ret;
}
void init()
{
    fac[1]=1;
    for(LL i=2; i<=M; i++)
        fac[i]=fac[i-1]*i%mod;
    inv_of_fac[M]=qpow(fac[M],mod-2);
    for(LL i=M-1; i>=0; i--)
        inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod;
}
LL C(LL a,LL b)
{
    if(b>a) return 0;
    if(b==0) return 1;
    return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod;
}
void pushdown(LL l,LL r,LL rt)//向下维护树内数据
{
    if(flag[rt])//如果贪婪标记不是0（说明需要向下进行覆盖区间（或点）的值）
    {
        LL m=(l+r)/2;
        flag[rt*2]+=flag[rt];
        flag[rt*2+1]+=flag[rt];
        tree[rt*2]+=(m-l+1)*flag[rt];//千万理解如何覆盖的区间值（对应线段树的图片理解（m-l）+1）是什么意识.
        tree[rt*2+1]+=(r-(m+1)+1)*flag[rt];
        flag[rt]=0;
    }
}
void pushup(LL rt)
{
    tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build( LL l ,LL r , LL rt )
{
    if( l == r )
    {
        tree[rt]=0;
        flag[rt]=0;
        return ;
    }
    else
    {
        LL m = (l+r)>>1 ;
        build(lson) ;
        build(rson) ;
        pushup(rt) ;
    }
}
void update(LL L,LL R,LL c,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)//覆盖的是区间~
    {
        tree[rt]+=c*((r-l)+1);//覆盖当前点的值
        flag[rt]+=c;//同时懒惰标记~！
        return ;
    }
    else
    {
        pushdown(l,r,rt);
        LL m=(l+r)/2;
        if(L<=m)
        {
            update(L,R,c,lson);
        }
        if(m<R)
        {
            update(L,R,c,rson);
        }
        pushup(rt);
    }
}
LL  Query(LL L,LL R,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)
    {
        return tree[rt];
    }
    pushdown(l,r,rt);
    LL m=(l+r)>>1;
    LL  ans=0;
    if(L<=m)
    {
        ans+=Query(L,R,lson);
    }
    if(m<R)
    {
        ans+=Query(L,R,rson);
    }
    return ans;
}
int main()
{
    init();
    LL n,k;
    while(~scanf("%I64d%I64d",&n,&k))
    {
        LL cnt=0;
        map<LL ,LL >s;
        map<LL ,LL >rs;
        memset(vis,0,sizeof(vis));
        memset(tree,0,sizeof(tree));
        memset(flag,0,sizeof(flag));
        for(LL i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&a[i].x,&a[i].y);
            b[cnt++]=a[i].x;b[cnt++]=a[i].y;
            b[cnt++]=a[i].x+1;b[cnt++]=a[i].y+1;
        }
        LL tot=0;sort(b,b+cnt);
        for(LL i=0;i<cnt;i++)
        {
            if(s[b[i]]==0)
            {
                s[b[i]]=++tot;
                rs[tot]=b[i];
            }
        }
        LL qq=0;
        build(1,tot,1);
        for(LL i=0;i<n;i++)
        {
            update(s[a[i].x],s[a[i].y],1,1,tot,1);
            vis[s[a[i].x]]=1;
            vis[s[a[i].y]]=1;
        }
        LL output=0;
        for(LL i=1;i<=tot;i++)
        {
            output+=C(Query(i,i,1,tot,1),k);
            output%=mod;
            if(rs[i]+1==rs[i+1])continue;
            else
            {
                output+=C(Query(i,i,1,tot,1),k)*(rs[i+1]-rs[i]-1);
                output%=mod;
            }
        }
        printf("%I64d\n",output);
    }
}
/*
4 1
1 10
2 9
15 20
16 21
*/


#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long int
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
struct node
{
    LL x,y;
}a[250000];
LL vis[2000000];
LL tree[2000000];
LL flag[2000000];
LL q[2000000];
const LL mod = 1000000007;
const LL N = 300000+5;
const LL M = 3e5+3;
LL b[5000000];
LL fac[1000005];            //阶乘
LL inv_of_fac[1000005];        //阶乘的逆元
LL qpow(LL x,LL n)
{
    LL ret=1;
    for(; n; n>>=1)
    {
        if(n&1) ret=ret*x%mod;
        x=x*x%mod;
    }
    return ret;
}
void init()
{
    fac[1]=1;
    for(LL i=2; i<=M; i++)
        fac[i]=fac[i-1]*i%mod;
    inv_of_fac[M]=qpow(fac[M],mod-2);
    for(LL i=M-1; i>=0; i--)
        inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod;
}
LL C(LL a,LL b)
{
    if(b>a) return 0;
    if(b==0) return 1;
    return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod;
}
void pushdown(LL l,LL r,LL rt)//向下维护树内数据
{
    if(flag[rt])//如果贪婪标记不是0（说明需要向下进行覆盖区间（或点）的值）
    {
        LL m=(l+r)/2;
        flag[rt*2]+=flag[rt];
        flag[rt*2+1]+=flag[rt];
        tree[rt*2]+=(m-l+1)*flag[rt];//千万理解如何覆盖的区间值（对应线段树的图片理解（m-l）+1）是什么意识.
        tree[rt*2+1]+=(r-(m+1)+1)*flag[rt];
        flag[rt]=0;
    }
}
void pushup(LL rt)
{
    tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build( LL l ,LL r , LL rt )
{
    if( l == r )
    {
        tree[rt]=0;
        flag[rt]=0;
        return ;
    }
    else
    {
        LL m = (l+r)>>1 ;
        build(lson) ;
        build(rson) ;
        pushup(rt) ;
    }
}
void update(LL L,LL R,LL c,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)//覆盖的是区间~
    {
        tree[rt]+=c*((r-l)+1);//覆盖当前点的值
        flag[rt]+=c;//同时懒惰标记~！
        return ;
    }
    else
    {
        pushdown(l,r,rt);
        LL m=(l+r)/2;
        if(L<=m)
        {
            update(L,R,c,lson);
        }
        if(m<R)
        {
            update(L,R,c,rson);
        }
        pushup(rt);
    }
}
LL  Query(LL L,LL R,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)
    {
        return tree[rt];
    }
    pushdown(l,r,rt);
    LL m=(l+r)>>1;
    LL  ans=0;
    if(L<=m)
    {
        ans+=Query(L,R,lson);
    }
    if(m<R)
    {
        ans+=Query(L,R,rson);
    }
    return ans;
}
int main()
{
    init();
    LL n,k;
    while(~scanf("%I64d%I64d",&n,&k))
    {
        LL cnt=0;
        map<LL ,LL >s;
        map<LL ,LL >rs;
        memset(vis,0,sizeof(vis));
        memset(tree,0,sizeof(tree));
        memset(flag,0,sizeof(flag));
        for(LL i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&a[i].x,&a[i].y);
            b[cnt++]=a[i].x;b[cnt++]=a[i].y;
            b[cnt++]=a[i].x+1;b[cnt++]=a[i].y+1;
        }
        LL tot=0;sort(b,b+cnt);
        for(LL i=0;i<cnt;i++)
        {
            if(s[b[i]]==0)
            {
                s[b[i]]=++tot;
                rs[tot]=b[i];
            }
        }
        LL qq=0;
        build(1,tot,1);
        for(LL i=0;i<n;i++)
        {
            update(s[a[i].x],s[a[i].y],1,1,tot,1);
            vis[s[a[i].x]]=1;
            vis[s[a[i].y]]=1;
        }
        LL output=0;
        for(LL i=1;i<=tot;i++)
        {
            output+=C(Query(i,i,1,tot,1),k);
            output%=mod;
            if(rs[i]+1==rs[i+1])continue;
            else
            {
                if(i==tot)continue;
                output+=C(Query(i,i,1,tot,1),k)*(rs[i+1]-rs[i]-1);
                output%=mod;
            }
        }
        printf("%I64d\n",output);
    }
}
/*
4 1
1 10
2 9
15 20
16 21
*/


#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long int
struct node
{
    LL x,y;
}a[250000];
const LL mod = 1000000007;
const LL N = 300000+5;
const LL M = 3e5+3;
LL b[5000000];
LL fac[1000005];            //阶乘
LL inv_of_fac[1000005];        //阶乘的逆元
LL qpow(LL x,LL n)
{
    LL ret=1;
    for(; n; n>>=1)
    {
        if(n&1) ret=ret*x%mod;
        x=x*x%mod;
    }
    return ret;
}
void init()
{
    fac[1]=1;
    for(LL i=2; i<=M; i++)
        fac[i]=fac[i-1]*i%mod;
    inv_of_fac[M]=qpow(fac[M],mod-2);
    for(LL i=M-1; i>=0; i--)
        inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod;
}
LL C(LL a,LL b)
{
    if(b>a) return 0;
    if(b==0) return 1;
    return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod;
}
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
LL tree[2000000];
LL flag[2000000];
void pushdown(LL l,LL r,LL rt)//向下维护树内数据
{
    if(flag[rt])//如果贪婪标记不是0（说明需要向下进行覆盖区间（或点）的值）
    {
        LL m=(l+r)/2;
        flag[rt*2]+=flag[rt];
        flag[rt*2+1]+=flag[rt];
        tree[rt*2]+=(m-l+1)*flag[rt];//千万理解如何覆盖的区间值（对应线段树的图片理解（m-l）+1）是什么意识.
        tree[rt*2+1]+=(r-(m+1)+1)*flag[rt];
        flag[rt]=0;
    }
}
void pushup(LL rt)
{
    tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build( LL l ,LL r , LL rt )
{
    if( l == r )
    {
        tree[rt]=0;
        flag[rt]=0;
        return ;
    }
    else
    {
        LL m = (l+r)>>1 ;
        build(lson) ;
        build(rson) ;
        pushup(rt) ;
    }
}
void update(LL L,LL R,LL c,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)//覆盖的是区间~
    {
        tree[rt]+=c*((r-l)+1);//覆盖当前点的值
        flag[rt]+=c;//同时懒惰标记~！
        return ;
    }
    else
    {
        pushdown(l,r,rt);
        LL m=(l+r)/2;
        if(L<=m)
        {
            update(L,R,c,lson);
        }
        if(m<R)
        {
            update(L,R,c,rson);
        }
        pushup(rt);
    }
}
LL  Query(LL L,LL R,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)
    {
        return tree[rt];
    }
    pushdown(l,r,rt);
    LL m=(l+r)>>1;
    LL  ans=0;
    if(L<=m)
    {
        ans+=Query(L,R,lson);
    }
    if(m<R)
    {
        ans+=Query(L,R,rson);
    }
    return ans;
}
int main()
{
    init();
    LL n,k;
    while(~scanf("%I64d%I64d",&n,&k))
    {
        LL cnt=0;
        map<LL ,LL >s;
        map<LL ,LL >rs;
        memset(tree,0,sizeof(tree));
        memset(flag,0,sizeof(flag));
        for(LL i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&a[i].x,&a[i].y);
            b[cnt++]=a[i].x;b[cnt++]=a[i].y;
        }
        LL tot=0;sort(b,b+cnt);
        for(LL i=0;i<cnt;i++)if(s[b[i]]==0)s[b[i]]=++tot,rs[tot]=b[i];
        rs[tot+1]=b[cnt-1]+1;
        build(1,tot,1);
        for(LL i=0;i<n;i++)
        {
            update(s[a[i].x],s[a[i].y],1,1,tot,1);
        }
        LL output=0;
        /*
        for(int i=1;i<=tot;i++)
        {
            printf("%d ",Query(i,i,1,tot,1));
        }
        printf("\n");*/
        for(int i=1;i<=tot;i++)
        {
            if(rs[i+1]-rs[i]==1)
            {
                output+=C(Query(i,i,1,tot,1),k);
                continue;
            }
            output+=min(C(Query(i,i,1,tot,1),k),C(Query(i+1,i+1,1,tot,1),k))*(rs[i+1]-rs[i]);
            if(Query(i,i,1,tot,1)!=Query(i+1,i+1,1,tot,1))output+=C(Query(i,i,1,tot,1),k);
            output%=mod;
        }
        printf("%I64d\n",output);
    }
}


#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long int
struct node
{
    LL x,y;
}a[250000];
const LL mod = 1000000007;
const LL N = 300000+5;
const LL M = 3e5+3;
LL b[5000000];
LL fac[1000005];            //阶乘
LL inv_of_fac[1000005];        //阶乘的逆元
LL qpow(LL x,LL n)
{
    LL ret=1;
    for(; n; n>>=1)
    {
        if(n&1) ret=ret*x%mod;
        x=x*x%mod;
    }
    return ret;
}
void init()
{
    fac[1]=1;
    for(LL i=2; i<=M; i++)
        fac[i]=fac[i-1]*i%mod;
    inv_of_fac[M]=qpow(fac[M],mod-2);
    for(LL i=M-1; i>=0; i--)
        inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod;
}
LL C(LL a,LL b)
{
    if(b>a) return 0;
    if(b==0) return 1;
    return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod;
}
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
LL tree[2000000];
LL flag[2000000];
void pushdown(LL l,LL r,LL rt)//向下维护树内数据
{
    if(flag[rt])//如果贪婪标记不是0（说明需要向下进行覆盖区间（或点）的值）
    {
        LL m=(l+r)/2;
        flag[rt*2]+=flag[rt];
        flag[rt*2+1]+=flag[rt];
        tree[rt*2]+=(m-l+1)*flag[rt];//千万理解如何覆盖的区间值（对应线段树的图片理解（m-l）+1）是什么意识.
        tree[rt*2+1]+=(r-(m+1)+1)*flag[rt];
        flag[rt]=0;
    }
}
void pushup(LL rt)
{
    tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build( LL l ,LL r , LL rt )
{
    if( l == r )
    {
        tree[rt]=0;
        flag[rt]=0;
        return ;
    }
    else
    {
        LL m = (l+r)>>1 ;
        build(lson) ;
        build(rson) ;
        pushup(rt) ;
    }
}
void update(LL L,LL R,LL c,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)//覆盖的是区间~
    {
        tree[rt]+=c*((r-l)+1);//覆盖当前点的值
        flag[rt]+=c;//同时懒惰标记~！
        return ;
    }
    else
    {
        pushdown(l,r,rt);
        LL m=(l+r)/2;
        if(L<=m)
        {
            update(L,R,c,lson);
        }
        if(m<R)
        {
            update(L,R,c,rson);
        }
        pushup(rt);
    }
}
LL  Query(LL L,LL R,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)
    {
        return tree[rt];
    }
    pushdown(l,r,rt);
    LL m=(l+r)>>1;
    LL  ans=0;
    if(L<=m)
    {
        ans+=Query(L,R,lson);
    }
    if(m<R)
    {
        ans+=Query(L,R,rson);
    }
    return ans;
}
int main()
{
    init();
    LL n,k;
    while(~scanf("%I64d%I64d",&n,&k))
    {
        LL cnt=0;
        map<LL ,LL >s;
        map<LL ,LL >rs;
        memset(tree,0,sizeof(tree));
        memset(flag,0,sizeof(flag));
        for(LL i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&a[i].x,&a[i].y);
            b[cnt++]=a[i].x;b[cnt++]=a[i].y;
        }
        LL tot=0;sort(b,b+cnt);
        for(LL i=0;i<cnt;i++)if(s[b[i]]==0)s[b[i]]=++tot,rs[tot]=b[i];
        rs[tot+1]=b[cnt-1]+1;
        build(1,tot,1);
        for(LL i=0;i<n;i++)
        {
            update(s[a[i].x],s[a[i].y],1,1,tot,1);
        }
        LL output=0;
        for(LL i=1;i<=tot;i++)
        {
            output+=C(Query(i,i,1,tot,1),k)*(rs[i+1]-rs[i]);
            output%=mod;
          //  printf("%I64d\n",Query(i,i,1,tot,1));
        }
        printf("%I64d\n",output);
    }
}


#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long int
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
struct node
{
    LL x,y;
}a[250000];
LL vis[2000000];
LL tree[2000000];
LL flag[2000000];
LL q[2000000];
const LL mod = 1000000007;
const LL N = 300000+5;
const LL M = 3e5+3;
LL b[5000000];
LL fac[1000005];            //阶乘
LL inv_of_fac[1000005];        //阶乘的逆元
LL qpow(LL x,LL n)
{
    LL ret=1;
    for(; n; n>>=1)
    {
        if(n&1) ret=ret*x%mod;
        x=x*x%mod;
    }
    return ret;
}
void init()
{
    fac[1]=1;
    for(LL i=2; i<=M; i++)
        fac[i]=fac[i-1]*i%mod;
    inv_of_fac[M]=qpow(fac[M],mod-2);
    for(LL i=M-1; i>=0; i--)
        inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod;
}
LL C(LL a,LL b)
{
    if(b>a) return 0;
    if(b==0) return 1;
    return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod;
}
void pushdown(LL l,LL r,LL rt)//向下维护树内数据
{
    if(flag[rt])//如果贪婪标记不是0（说明需要向下进行覆盖区间（或点）的值）
    {
        LL m=(l+r)/2;
        flag[rt*2]+=flag[rt];
        flag[rt*2+1]+=flag[rt];
        tree[rt*2]+=(m-l+1)*flag[rt];//千万理解如何覆盖的区间值（对应线段树的图片理解（m-l）+1）是什么意识.
        tree[rt*2+1]+=(r-(m+1)+1)*flag[rt];
        flag[rt]=0;
    }
}
void pushup(LL rt)
{
    tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build( LL l ,LL r , LL rt )
{
    if( l == r )
    {
        tree[rt]=0;
        flag[rt]=0;
        return ;
    }
    else
    {
        LL m = (l+r)>>1 ;
        build(lson) ;
        build(rson) ;
        pushup(rt) ;
    }
}
void update(LL L,LL R,LL c,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)//覆盖的是区间~
    {
        tree[rt]+=c*((r-l)+1);//覆盖当前点的值
        flag[rt]+=c;//同时懒惰标记~！
        return ;
    }
    else
    {
        pushdown(l,r,rt);
        LL m=(l+r)/2;
        if(L<=m)
        {
            update(L,R,c,lson);
        }
        if(m<R)
        {
            update(L,R,c,rson);
        }
        pushup(rt);
    }
}
LL  Query(LL L,LL R,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)
    {
        return tree[rt];
    }
    pushdown(l,r,rt);
    LL m=(l+r)>>1;
    LL  ans=0;
    if(L<=m)
    {
        ans+=Query(L,R,lson);
    }
    if(m<R)
    {
        ans+=Query(L,R,rson);
    }
    return ans;
}
int main()
{
    init();
    LL n,k;
    while(~scanf("%I64d%I64d",&n,&k))
    {
        LL cnt=0;
        map<LL ,LL >s;
        map<LL ,LL >rs;
        memset(vis,0,sizeof(vis));
        memset(tree,0,sizeof(tree));
        memset(flag,0,sizeof(flag));
        for(LL i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&a[i].x,&a[i].y);
            b[cnt++]=a[i].x;b[cnt++]=a[i].y;
            b[cnt++]=a[i].x+1;b[cnt++]=a[i].y+1;
        }
        LL tot=0;sort(b,b+cnt);
        for(LL i=0;i<cnt;i++)
        {
            if(s[b[i]]==0)
            {
                s[b[i]]=++tot;
                rs[tot]=b[i];
            }
        }
        LL qq=0;
        build(1,tot,1);
        for(LL i=0;i<n;i++)
        {
            update(s[a[i].x],s[a[i].y],1,1,tot,1);
            vis[s[a[i].x]]=1;
            vis[s[a[i].y]]=1;
        }
        LL output=0;
        /*
        for(LL i=1;i<=tot;i++)
        {
            printf("%I64d ",rs[i]);
        }
        printf("\n");*/
        for(LL i=1;i<=tot;i++)
        {
            output+=C(Query(i,i,1,tot,1),k);
            output%=mod;
           // printf("--------%I64d\n",C(Query(i,i,1,tot,1),k));
            if(rs[i]+1==rs[i+1])continue;
            else
            {
                output+=C(Query(i,i,1,tot,1),k)*(rs[i+1]-rs[i]-1);
                output%=mod;
               // printf("-%I64d %I64d\n",rs[i],rs[i+1]);
            }
        }
        printf("%I64d\n",output);
    }
}
/*
4 1
1 10
2 9
15 20
16 21
*/


#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
const LL mod = 1000000007;
const LL N = 500000+5;
const LL M = 5e5+3;
#define LL long long int
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
struct node
{
    LL x,y;
}a[250000];
LL vis[3000000];
LL tree[3000000];
LL flag[3000000];
LL q[3000000];
LL b[5000000];
LL fac[3000005];            //阶乘
LL inv_of_fac[3000005];        //阶乘的逆元
LL qpow(LL x,LL n)
{
    LL ret=1;
    for(; n; n>>=1)
    {
        if(n&1) ret=ret*x%mod;
        x=x*x%mod;
    }
    return ret;
}
void init()
{
    fac[1]=1;
    for(LL i=2; i<=M; i++)
        fac[i]=fac[i-1]*i%mod;
    inv_of_fac[M]=qpow(fac[M],mod-2);
    for(LL i=M-1; i>=0; i--)
        inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod;
}
LL C(LL a,LL b)
{
    if(b>a) return 0;
    if(b==0) return 1;
    return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod;
}
void pushdown(LL l,LL r,LL rt)//向下维护树内数据
{
    if(flag[rt])//如果贪婪标记不是0（说明需要向下进行覆盖区间（或点）的值）
    {
        LL m=(l+r)/2;
        flag[rt*2]+=flag[rt];
        flag[rt*2+1]+=flag[rt];
        tree[rt*2]+=(m-l+1)*flag[rt];//千万理解如何覆盖的区间值（对应线段树的图片理解（m-l）+1）是什么意识.
        tree[rt*2+1]+=(r-(m+1)+1)*flag[rt];
        flag[rt]=0;
    }
}
void pushup(LL rt)
{
    tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build( LL l ,LL r , LL rt )
{
    if( l == r )
    {
        tree[rt]=0;
        flag[rt]=0;
        return ;
    }
    else
    {
        LL m = (l+r)>>1 ;
        build(lson) ;
        build(rson) ;
        pushup(rt) ;
    }
}
void update(LL L,LL R,LL c,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)//覆盖的是区间~
    {
        tree[rt]+=c*((r-l)+1);//覆盖当前点的值
        flag[rt]+=c;//同时懒惰标记~！
        return ;
    }
    else
    {
        pushdown(l,r,rt);
        LL m=(l+r)/2;
        if(L<=m)
        {
            update(L,R,c,lson);
        }
        if(m<R)
        {
            update(L,R,c,rson);
        }
        pushup(rt);
    }
}
LL  Query(LL L,LL R,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)
    {
        return tree[rt];
    }
    pushdown(l,r,rt);
    LL m=(l+r)>>1;
    LL  ans=0;
    if(L<=m)
    {
        ans+=Query(L,R,lson);
    }
    if(m<R)
    {
        ans+=Query(L,R,rson);
    }
    return ans;
}
int main()
{
    init();
    LL n,k;
    while(~scanf("%I64d%I64d",&n,&k))
    {
        LL cnt=0;
        map<LL ,LL >s;
        map<LL ,LL >rs;
        memset(vis,0,sizeof(vis));
        memset(tree,0,sizeof(tree));
        memset(flag,0,sizeof(flag));
        for(LL i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&a[i].x,&a[i].y);
            b[cnt++]=a[i].x;b[cnt++]=a[i].y;
            b[cnt++]=a[i].x+1;b[cnt++]=a[i].y+1;
        }
        LL tot=0;sort(b,b+cnt);
        for(LL i=0;i<cnt;i++)
        {
            if(s[b[i]]==0)
            {
                s[b[i]]=++tot;
                rs[tot]=b[i];
            }
        }
        LL qq=0;
        build(1,tot,1);
        for(LL i=0;i<n;i++)
        {
            update(s[a[i].x],s[a[i].y],1,1,tot,1);
            vis[s[a[i].x]]=1;
            vis[s[a[i].y]]=1;
        }
        LL output=0;
        for(LL i=1;i<=tot;i++)
        {
            output+=C(Query(i,i,1,tot,1),k);
            output%=mod;
            if(rs[i]+1==rs[i+1])continue;
            else
            {
                output+=C(Query(i,i,1,tot,1),k)*(rs[i+1]-rs[i]-1);
                output%=mod;
            }
        }
        printf("%I64d\n",output);
    }
}
/*
4 1
1 10
2 9
15 20
16 21
*/


#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
#define LL long long int
#define lson l,m,rt*2
#define rson m+1,r,rt*2+1
struct node
{
    LL x,y;
}a[250000];
LL vis[2000000];
LL tree[2000000];
LL flag[2000000];
const LL mod = 1000000007;
const LL N = 300000+5;
const LL M = 3e5+3;
LL b[5000000];
LL fac[1000005];            //阶乘
LL inv_of_fac[1000005];        //阶乘的逆元
LL qpow(LL x,LL n)
{
    LL ret=1;
    for(; n; n>>=1)
    {
        if(n&1) ret=ret*x%mod;
        x=x*x%mod;
    }
    return ret;
}
void init()
{
    fac[1]=1;
    for(LL i=2; i<=M; i++)
        fac[i]=fac[i-1]*i%mod;
    inv_of_fac[M]=qpow(fac[M],mod-2);
    for(LL i=M-1; i>=0; i--)
        inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod;
}
LL C(LL a,LL b)
{
    if(b>a) return 0;
    if(b==0) return 1;
    return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod;
}
void pushdown(LL l,LL r,LL rt)//向下维护树内数据
{
    if(flag[rt])//如果贪婪标记不是0（说明需要向下进行覆盖区间（或点）的值）
    {
        LL m=(l+r)/2;
        flag[rt*2]+=flag[rt];
        flag[rt*2+1]+=flag[rt];
        tree[rt*2]+=(m-l+1)*flag[rt];//千万理解如何覆盖的区间值（对应线段树的图片理解（m-l）+1）是什么意识.
        tree[rt*2+1]+=(r-(m+1)+1)*flag[rt];
        flag[rt]=0;
    }
}
void pushup(LL rt)
{
    tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void build( LL l ,LL r , LL rt )
{
    if( l == r )
    {
        tree[rt]=0;
        flag[rt]=0;
        return ;
    }
    else
    {
        LL m = (l+r)>>1 ;
        build(lson) ;
        build(rson) ;
        pushup(rt) ;
    }
}
void update(LL L,LL R,LL c,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)//覆盖的是区间~
    {
        tree[rt]+=c*((r-l)+1);//覆盖当前点的值
        flag[rt]+=c;//同时懒惰标记~！
        return ;
    }
    else
    {
        pushdown(l,r,rt);
        LL m=(l+r)/2;
        if(L<=m)
        {
            update(L,R,c,lson);
        }
        if(m<R)
        {
            update(L,R,c,rson);
        }
        pushup(rt);
    }
}
LL  Query(LL L,LL R,LL l,LL r,LL rt)
{
    if(L<=l&&r<=R)
    {
        return tree[rt];
    }
    pushdown(l,r,rt);
    LL m=(l+r)>>1;
    LL  ans=0;
    if(L<=m)
    {
        ans+=Query(L,R,lson);
    }
    if(m<R)
    {
        ans+=Query(L,R,rson);
    }
    return ans;
}
int main()
{
    init();
    LL n,k;
    while(~scanf("%I64d%I64d",&n,&k))
    {
        LL cnt=0;
        map<LL ,LL >s;
        map<LL ,LL >rs;
        memset(vis,0,sizeof(vis));
        memset(tree,0,sizeof(tree));
        memset(flag,0,sizeof(flag));
        for(LL i=0;i<n;i++)
        {
            scanf("%I64d%I64d",&a[i].x,&a[i].y);
            b[cnt++]=a[i].x;b[cnt++]=a[i].y;
        }
        LL tot=0;sort(b,b+cnt);
        for(LL i=0;i<cnt;i++)if(s[b[i]]==0)s[b[i]]=++tot,rs[tot]=b[i];
        rs[tot+1]=b[cnt-1]+1;
        build(1,tot,1);
        for(LL i=0;i<n;i++)
        {
            update(s[a[i].x],s[a[i].y],1,1,tot,1);
        }
        LL output=0;
        /*
        for(int i=1;i<=tot;i++)
        {
            printf("%I64d ",Query(i,i,1,tot,1));
        }
        printf("\n");*/
        for(int i=1;i<=tot;i++)
        {
            if(rs[i+1]-rs[i]==1)
            {
                vis[i]=1;
                output+=C(Query(i,i,1,tot,1),k);
                output%=mod;
                continue;
            }
            if(Query(i,i,1,tot,1)<=Query(i+1,i+1,1,tot,1))
            {
                output+=C(Query(i,i,1,tot,1),k)*(rs[i+1]-rs[i]);
                if(vis[i]==1)output-=C(Query(i,i,1,tot,1),k);
                vis[i]=1;
            }
            else
            {
                output+=C(Query(i+1,i+1,1,tot,1),k)*(rs[i+1]-rs[i]);
                vis[i+1]=1;
                if(vis[i]==0)output+=C(Query(i,i,1,tot,1),k);
                vis[i]=1;
            }
            output%=mod;
        }
        printf("%I64d\n",output);
      //  printf("%I64d\n",output);
    }
}


#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
pair<int,int>pp[N+2];
const int mod=1e9+7;
int big(int b,int p,int m=mod)
{
  int ret=1;
  while(p){if(p&1)ret=(1LL*ret*b)%m;b=(1LL*b*b)%m;p/=2;}
  return ret;
}
int fac[N+2];
void init(int n)
{
  fac[0]=1;
  for(int i=1;i<=n;i++)fac[i]=(1LL*fac[i-1]*i)%mod;
}
int ncr(int n,int r)
{
  int a=fac[n];a=(1LL*a*big(fac[r],mod-2))%mod;
  return (1LL*a*big(fac[n-r],mod-2))%mod;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;
  int id=0;
  for(int i=1;i<=n;i++)
  {
    int l,r;cin>>l>>r;
    pp[++id]={l,-1};pp[++id]={r,1};
  }
  sort(pp+1,pp+id+1);init(N);
  int cnt=0,ans=0,ls;
  for(int i=1;i<=id;i++)
  {
    if(pp[i].second<0)
    {
      if(cnt>=k)
      {
        int nm=pp[i].first-ls;if(nm==-1)assert(0);
        ans=(1LL*ans+1LL*nm*ncr(cnt,k))%mod;
      }
      cnt++;ls=pp[i].first;
    }
    else
    {
      if(cnt>=k)
      {
        int nm=pp[i].first-ls+1;if(nm==-1)assert(0);
        ans=(1LL*ans+1LL*nm*ncr(cnt,k))%mod;
      }
      cnt--;ls=pp[i].first+1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mx 300005
#define int long long
#define pii pair <int, int>
#define piii pair <int, pii>
#define fi first
#define se second
#define mod 1000000007
#define inf 1e18+19
#define pb push_back
#define mem(ara, x) memset(ara, x, sizeof ara)
#define read() freopen("in.txt", "r", stdin)
#define write() freopen("out.txt", "w", stdout)
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

map <int, int> mp;
pii ara[mx];
int f[mx];

int bigmod(int a, int b){
    if(!b) return 1%mod;
    int c = bigmod(a, b/2);
    c = (c*c)%mod;
    if(b%2) c = (c*a)%mod;
    return c;
}

int fac(int i){
    if(i==0) return 1;
    if(f[i]!=-1) return f[i];
    return f[i] = (i*fac(i-1))%mod;
}

int revfac(int i){
    return bigmod(fac(i), mod-2);
}

int C(int n, int r){
    return (((fac(n) * revfac(n-r))%mod) * revfac(r))%mod;
}

int32_t main(){
    //read();
    fst;
    int n, k;
    mem(f, -1);
    while(cin >> n >> k){
        for(int i=0;i<n;i++){
            cin >> ara[i].fi >> ara[i].se;
            mp[ara[i].fi]++;
            mp[ara[i].se+1]--;
        }
        int l = mp.begin()->fi;
        int sum = 0, ans = 0;
        for(map <int, int> :: iterator it = mp.begin();it!=mp.end();it++){
            int d = it->fi - l;
            if(sum>=k){
                ans = (ans + C(sum, k)*d)%mod;
            }
            l = it->fi;
            sum += it->se;
            //cout << it->fi << " " << it->se << endl;
        }
        cout << ans << endl;
        mp.clear();
    }
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#include <stack>
#include <set>
#include <map>
#define LSON l,m,x<<1
#define RSON m+1,r,x<<1|1
using namespace std;

const int MAX=2e5+5;
const int p=1e9+7;
long long n,k;
long long l[MAX],r[MAX],d[MAX],cnt[MAX];
vector<long long> V;

int find(long long x){
	return lower_bound(V.begin(),V.end(),x)-V.begin();
}

long long quick_mod(long long a, long long b){
    long long ans=1;

    a%=p;
    while(b){
        if(b&1){
            ans=ans*a%p;
            b--;
        }
        b>>=1;
        a=a*a%p;
    }
    return ans;
}

long long C(long long n, long long m){
	long long i;
	long long ans=1;

    if(m>n)
	    return 0;
    for(i=1;i<=m;i++){
        long long a=(n+i-m)%p;
        long long b=i%p;
        ans=ans*(a*quick_mod(b,p-2)%p)%p;
    }
    return ans;
}

long long Lucas(long long n, long long m){
    if(m==0)
	    return 1;
    return C(n%p,m%p)*Lucas(n/p,m/p)%p;
}

int main(){
	int i;
	long long ans=0,tmp;

	scanf("%lld%lld",&n,&k);
	for(i=0;i<n;i++){
		scanf("%lld%lld",&l[i],&r[i]);
		l[i]--;
		V.push_back(l[i]);
		V.push_back(r[i]);
	}
	sort(V.begin(),V.end());
	V.resize(unique(V.begin(),V.end())-V.begin());
	for(i=0;i<V.size()-1;i++)
	    d[i]=V[i+1]-V[i];
	for(i=0;i<n;i++){
		cnt[find(l[i])]++;
		cnt[find(r[i])]--;
	}
	for(i=1;i<V.size()-1;i++){
	    cnt[i]+=cnt[i-1];
	    tmp=Lucas(cnt[i],k)%p;
	    tmp=tmp*d[i]%p;
	    ans=(ans+tmp)%p;
	}
	printf("%lld\n",ans);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#include <stack>
#include <set>
#include <map>
#define LSON l,m,x<<1
#define RSON m+1,r,x<<1|1
using namespace std;

const int MAX=2e5+5;
const int mod=1e9+7;
long long n,k;
long long l[MAX],r[MAX],d[MAX],cnt[MAX];
vector<long long> V;

int find(long long x){
	return lower_bound(V.begin(),V.end(),x)-V.begin();
}

long long fac[MAX]; //阶乘

long long quick(long long x, long long n){  //快速幂
    long long ans=1;

    if(x==0)
		return 0;
    while(n){
        if(n&1)
			ans=(ans*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return ans;
}

void init(void){  //记得初始化
	int i;

    fac[0]=1;
    for(i=1;i<MAX;i++)
		fac[i]=(fac[i-1]*i)%mod;
}

long long Inv(long long n){  //求逆元
    return quick(n,mod-2);
}

long long C(long long n,long long m){
    return fac[n]*(Inv(fac[m]*fac[n-m]%mod))%mod;
}

int main(){
	int i;
	long long ans=0,tmp;

	init();
	scanf("%lld%lld",&n,&k);
	for(i=0;i<n;i++){
		scanf("%lld%lld",&l[i],&r[i]);
		l[i]--;
		V.push_back(l[i]);
		V.push_back(r[i]);
	}
	sort(V.begin(),V.end());
	V.resize(unique(V.begin(),V.end())-V.begin());
	for(i=0;i<V.size()-1;i++)
	    d[i]=V[i+1]-V[i];
	for(i=0;i<n;i++){
		cnt[find(l[i])]++;
		cnt[find(r[i])]--;
	}
	for(i=0;i<V.size()-1;i++){
		if(i>0)
	    	cnt[i]+=cnt[i-1];
	    if(cnt[i]>=k){
		    tmp=C(cnt[i],k)%mod;
		    tmp=tmp*d[i]%mod;
		    ans=(ans+tmp)%mod;
		}
	}
	printf("%lld\n",ans);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#include <stack>
#include <set>
#include <map>
#define LSON l,m,x<<1
#define RSON m+1,r,x<<1|1
using namespace std;

const int MAX=2e5+5;
const int p=1e9+7;
int n,k;
int l[MAX],r[MAX],d[MAX],cnt[MAX];
vector<int> V;

int find(int x){
	return lower_bound(V.begin(),V.end(),x)-V.begin();
}

long long quick_mod(long long a, long long b){
    long long ans=1;

    a%=p;
    while(b){
        if(b&1){
            ans=ans*a%p;
            b--;
        }
        b>>=1;
        a=a*a%p;
    }
    return ans;
}

long long C(long long n, long long m){
	int i;
	long long ans=1;

    if(m>n)
	    return 0;
    for(i=1;i<=m;i++){
        long long a=(n+i-m)%p;
        long long b=i%p;
        ans=ans*(a*quick_mod(b,p-2)%p)%p;
    }
    return ans;
}

long long Lucas(long long n, long long m){
    if(m==0)
	    return 1;
    return C(n%p,m%p)*Lucas(n/p,m/p)%p;
}

int main(){
	int i;
	long long ans=0,tmp;

	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d%d",&l[i],&r[i]);
		l[i]--;
		V.push_back(l[i]);
		V.push_back(r[i]);
	}
	sort(V.begin(),V.end());
	V.resize(unique(V.begin(),V.end())-V.begin());
	for(i=0;i<V.size()-1;i++)
	    d[i]=V[i+1]-V[i];
	for(i=0;i<V.size()-1;i++){
		cnt[find(l[i])]++;
		cnt[find(r[i])]--;
	}
	for(i=1;i<V.size()-1;i++)
	    cnt[i]+=cnt[i-1];
	for(i=0;i<V.size()-1;i++){
		if(cnt[i]>=k){
		    tmp=Lucas(cnt[i],k)%p;
		    tmp=tmp*d[i]%p;
		    ans=(ans+tmp)%p;
		}
	}
	printf("%lld\n",ans);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#include <stack>
#include <set>
#include <map>
#define LSON l,m,x<<1
#define RSON m+1,r,x<<1|1
using namespace std;

const int MAX=2e5+5;
const int p=1e9+7;
long long n,k;
long long l[MAX],r[MAX],d[MAX],cnt[MAX];
vector<long long> V;

int find(long long x){
	return lower_bound(V.begin(),V.end(),x)-V.begin();
}

long long quick_mod(long long a, long long b){
    long long ans=1;

    a%=p;
    while(b){
        if(b&1){
            ans=ans*a%p;
            b--;
        }
        b>>=1;
        a=a*a%p;
    }
    return ans;
}

long long C(long long n, long long m){
	int i;
	long long ans=1;

    if(m>n)
	    return 0;
    for(i=1;i<=m;i++){
        long long a=(n+i-m)%p;
        long long b=i%p;
        ans=ans*(a*quick_mod(b,p-2)%p)%p;
    }
    return ans;
}

long long Lucas(long long n, long long m){
    if(m==0)
	    return 1;
    return C(n%p,m%p)*Lucas(n/p,m/p)%p;
}

int main(){
	int i;
	long long ans=0,tmp;

	scanf("%lld%lld",&n,&k);
	for(i=0;i<n;i++){
		scanf("%lld%lld",&l[i],&r[i]);
		l[i]--;
		V.push_back(l[i]);
		V.push_back(r[i]);
	}
	sort(V.begin(),V.end());
	V.resize(unique(V.begin(),V.end())-V.begin());
	for(i=0;i<V.size()-1;i++)
	    d[i]=V[i+1]-V[i];
	for(i=0;i<n;i++){
		cnt[find(l[i])]++;
		cnt[find(r[i])]--;
	}
	for(i=1;i<V.size()-1;i++)
	    cnt[i]+=cnt[i-1];
	for(i=0;i<V.size()-1;i++){
		if(cnt[i]>=k){
		    tmp=Lucas(cnt[i],k)%p;
		    tmp=tmp*d[i]%p;
		    ans=(ans+tmp)%p;
		}
	}
	printf("%lld\n",ans);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#include <stack>
#include <set>
#include <map>
#define LSON l,m,x<<1
#define RSON m+1,r,x<<1|1
using namespace std;

const int MAX=2e5+5;
const int mod=1e9+7;
int n,k;
int l[MAX],r[MAX],rec[MAX*2],num,cnt[MAX*2];
long long fac[MAX];

int find(long long x){
	return lower_bound(rec,rec+num,x)-rec;
}

long long quick(long long x, long long n){
    long long ans=1;

    if(x==0)
		return 0;
    while(n){
        if(n&1)
			ans=(ans*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return ans;
}

void init(void){
	int i;

    fac[0]=1;
    for(i=1;i<MAX;i++)
		fac[i]=(fac[i-1]*i)%mod;
}

long long Inv(long long n){
    return quick(n,mod-2);
}

long long C(long long n,long long m){
    return fac[n]*(Inv(fac[m]*fac[n-m]%mod))%mod;
}

int main(){
	int i;
	int ans=0,tk;

	init();
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d%d",&l[i],&r[i]);
		rec[num++]=l[i];
		rec[num++]=++r[i];
	}
	sort(rec,rec+num);
	num=unique(rec,rec+num)-rec;
	for(i=0;i<n;i++){
		cnt[find(l[i])]++;
		cnt[find(r[i])]--;
	}
	tk=cnt[0];
	for(i=1;i<num;i++){
	    if(tk>=k)
		    ans=(ans+C(tk,k)*((rec[i]-rec[i-1])%mod)%mod)%mod;
		tk+=cnt[i];
	}
	printf("%d\n",ans);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#include <stack>
#include <set>
#include <map>
#define LSON l,m,x<<1
#define RSON m+1,r,x<<1|1
using namespace std;

const int MAX=2e5+5;
const int p=1e9+7;
int n,k;
int l[MAX],r[MAX],d[MAX],cnt[MAX];
vector<int> V;

int find(int x){
	return lower_bound(V.begin(),V.end(),x)-V.begin();
}

long long quick_mod(long long a, long long b){
    long long ans=1;

    a%=p;
    while(b){
        if(b&1){
            ans=ans*a%p;
            b--;
        }
        b>>=1;
        a=a*a%p;
    }
    return ans;
}

long long C(long long n, long long m){
	int i;
	long long ans=1;

    if(m>n)
	    return 0;
    for(i=1;i<=m;i++){
        long long a=(n+i-m)%p;
        long long b=i%p;
        ans=ans*(a*quick_mod(b,p-2)%p)%p;
    }
    return ans;
}

long long Lucas(long long n, long long m){
    if(m==0)
	    return 1;
    return C(n%p,m%p)*Lucas(n/p,m/p)%p;
}

int main(){
	int i;
	long long ans=0;

	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d%d",&l[i],&r[i]);
		l[i]--;
		V.push_back(l[i]);
		V.push_back(r[i]);
	}
	sort(V.begin(),V.end());
	V.reserve(unique(V.begin(),V.end())-V.begin());
	for(i=0;i<V.size()-1;i++)
	    d[i]=V[i+1]-V[i];
	for(i=0;i<V.size()-1;i++){
		cnt[find(l[i])]++;
		cnt[find(r[i])]--;
	}
	for(i=1;i<V.size()-1;i++)
	    cnt[i]+=cnt[i-1];
	for(i=0;i<V.size()-1;i++){
		if(cnt[i]>=k){
		    ans=(ans+Lucas(cnt[i],k))%p;
		    ans=ans*d[i]%p;
		}
	}
	printf("%lld\n",ans);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#include <stack>
#include <set>
#include <map>
#define LSON l,m,x<<1
#define RSON m+1,r,x<<1|1
using namespace std;

const int MAX=2e5+5;
const int p=1e9+7;
int n,k;
int l[MAX],r[MAX],rec[MAX*2],num;
long long cnt[MAX];

int find(long long x){
	return lower_bound(rec,rec+num,x)-rec;
}

long long quick_mod(long long a, long long b){
    long long ans=1;

    a%=p;
    while(b){
        if(b&1){
            ans=ans*a%p;
            b--;
        }
        b>>=1;
        a=a*a%p;
    }
    return ans;
}

long long C(long long n, long long m){
	long long i;
	long long ans=1;

    if(m>n)
	    return 0;
    for(i=1;i<=m;i++){
        long long a=(n+i-m)%p;
        long long b=i%p;
        ans=ans*(a*quick_mod(b,p-2)%p)%p;
    }
    return ans;
}

long long Lucas(long long n, long long m){
    if(m==0)
	    return 1;
    return C(n%p,m%p)*Lucas(n/p,m/p)%p;
}

int main(){
	int i;
	int ans=0,tk;

	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d%d",&l[i],&r[i]);
		rec[num++]=l[i];
		rec[num++]=++r[i];
	}
	sort(rec,rec+num);
	num=unique(rec,rec+num)-rec;
	for(i=0;i<n;i++){
		cnt[find(l[i])]++;
		cnt[find(r[i])]--;
	}
	tk=cnt[0];
	for(i=1;i<num;i++){
	    if(tk>=k)
		    ans=(ans+Lucas(tk,k)*((rec[i]-rec[i-1])%p)%p)%p;
		tk+=cnt[i];
	}
	printf("%d\n",ans);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#include <stack>
#include <set>
#include <map>
#define LSON l,m,x<<1
#define RSON m+1,r,x<<1|1
using namespace std;

const int MAX=2e5+5;
const int p=1e9+7;
int n,k;
int l[MAX],r[MAX],d[MAX],cnt[MAX];
vector<int> V;

int find(int x){
	return lower_bound(V.begin(),V.end(),x)-V.begin();
}

long long quick_mod(long long a, long long b){
    long long ans=1;

    a%=p;
    while(b){
        if(b&1){
            ans=ans*a%p;
            b--;
        }
        b>>=1;
        a=a*a%p;
    }
    return ans;
}

long long C(long long n, long long m){
	int i;
	long long ans=1;

    if(m>n)
	    return 0;
    for(i=1;i<=m;i++){
        long long a=(n+i-m)%p;
        long long b=i%p;
        ans=ans*(a*quick_mod(b,p-2)%p)%p;
    }
    return ans;
}

long long Lucas(long long n, long long m){
    if(m==0)
	    return 1;
    return C(n%p,m%p)*Lucas(n/p,m/p)%p;
}

int main(){
	int i;
	long long ans=0,tmp;

	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d%d",&l[i],&r[i]);
		l[i]--;
		V.push_back(l[i]);
		V.push_back(r[i]);
	}
	sort(V.begin(),V.end());
	V.resize(unique(V.begin(),V.end())-V.begin());
	for(i=0;i<V.size()-1;i++)
	    d[i]=V[i+1]-V[i];
	for(i=0;i<n;i++){
		cnt[find(l[i])]++;
		cnt[find(r[i])]--;
	}
	for(i=1;i<V.size()-1;i++)
	    cnt[i]+=cnt[i-1];
	for(i=0;i<V.size()-1;i++){
		if(cnt[i]>=k){
		    tmp=Lucas(cnt[i],k)%p;
		    tmp=tmp*d[i]%p;
		    ans=(ans+tmp)%p;
		}
	}
	printf("%lld\n",ans);

	return 0;
}