#include <bits/stdc++.h>   using namespace std;   bool comp(long long a, long long b) { return a > b; }   std::vector<long long> fac(500000);   void pre() {     fac[0] = 1;     for (int i = 1; i < 500000; i++) {       fac[i] = i * fac[i - 1];       fac[i] %= 998244353;     }   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long modInverse(long long n, long long p) { return power(n, p - 2, p); }   long long nCrModPFermat(long long n, long long r) {     if (n <= 0 || n < r) return 0;     if (r == 0) return 1;     long long a = (fac[n] * modInverse(fac[r], 998244353) % 998244353 *                    modInverse(fac[n - r], 998244353) % 998244353) %                   998244353;     return a;   }   void solve() {     long long k, x, y, n;     cin >> n >> k;     std::vector<pair<long long, long long>> ar;     long long ans = 0;     for (int i = 0; i < n; i++) {       long long l, r;       cin >> l >> r;       ar.push_back(make_pair(l, r));     }     if (k == 1) {       cout << n <<   n ;       return;     }     sort(ar.begin(), ar.end());     multiset<long long> q;     long long cnt;     for (int i = 0; i < n; i++) {       while (!q.empty() && *q.begin() < ar[i].first) {         q.erase(q.begin());       }       cnt = q.size();       ans += (nCrModPFermat(cnt, k - 1));       ans %= 998244353;       q.insert(ar[i].second);     }     cout << ans <<   n ;   }   int main() {     pre();     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     while (t--) solve();     return 0;   }   