Given segment: s[0], s[1], ..., s[k]
If each segment need to have at least one intersection point <=>
max(l[s[0]], l[s[1]], l[s[2]], ... , l[s[k]]) <= min(r[s[0]], r[s[1]], r[s[2]], ..., r[s[k]])
Once assume l[s[0]] <= l[s[1]] <= ... <= l[s[k]]:
max(l[s[0]], l[s[1]], l[s[2]], ... , l[s[k]]) = l[s[k]] <= min(r[s[0]], r[s[1]], r[s[2]], ..., r[s[k]])
=> l[s[k]] <= r[s[0] && l[s[k]] <= r[s[1]] && l[s[k]] <= r[s[2]] && ... && l[s[k]] <= r[s[k-1]]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int MAXN = 3e5 + 10;
ll Fac[MAXN] = {1};
int Fs = 0;
ll inv[MAXN];
ll qpow(ll base, ll power) {
ll res = 1;
while(power) {
if(power & 1) res = (res * base) % mod;
base = (base * base) % mod;
power >>= 1;
}
return res % mod;
}
void init() {
for(int i = 1; i < MAXN; i++) {
Fac[i] = Fac[i-1] * i % mod;
}
inv[MAXN - 1] = qpow(Fac[MAXN-1], mod-2);
for(int i = MAXN - 2; i >= 0; i--) inv[i] = inv[i+1] * (i+1) % mod;
cerr<<inv[0]<<'\n';
}
ll Comb(ll n, ll m) {
if(n < m) return 0;
if(m < 0) return 0;
return (((Fac[n]*inv[n-m])%mod)*inv[m])%mod;
}
int main() {
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
init();
int n, k;
cin>>n>>k;
vector<int> l(n);
vector<int> r(n);
for(int i = 0; i < n; i++) cin>>l[i]>>r[i];
vector<int> order(n);
iota(order.begin(), order.end(), 0);
sort(order.begin(), order.end(), [&](int i, int j) {
return l[i] < l[j];
});
ll ans = 0;
multiset<int> rs;
for(int i: order) {
while (!rs.empty() && *rs.begin() < l[i]) {
rs.erase(rs.begin());
}
int cnt = (int)rs.size();
// cerr<<cnt<<" "<<k-1<<'\n';
ans = (ans + Comb(cnt, k-1)) % mod;
rs.insert(r[i]);
}
cout << ans << '\n';
return 0;
}