#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
void d_err() { cerr << endl; }
template <typename H, typename... T>
void d_err(H h, T... t) {
  cerr << h << " ";
  d_err(t...);
}
template <typename T>
void print(T x) {
  cout << x << "\n";
}
long long INF = 1e16;
int inf = 1e9;
long long MOD = 998244353;
struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> lr;
  for (int i = (0); i < (n); ++i) {
    int l, r;
    cin >> l >> r;
    lr.emplace_back(l, r);
  }
  sort((lr).begin(), (lr).end());
  vector<mint> dp(n, 0);
  dp[0] = 1;
  vector<mint> s(k, 0);
  for (int i = (1); i < (n); ++i) {
    for (int j = (0); j < (k); ++j) {
      int l = lr[j].first, r = lr[j].second;
      if (i - l >= 0) s[j] += dp[i - l];
      if (i - r >= 1) s[j] -= dp[i - r - 1];
      dp[i] += s[j];
    }
  }
  print(dp[n - 1]);
}
