#include <bits/stdc++.h>
const long long N = 55, M = 100005, P = 998244353;
long long n, m, l[N], r[N], f[N][M], ans[M];
signed main() {
  std::cin >> n >> m;
  for (long long i = 1; i <= n; i++) std::cin >> l[i] >> r[i];
  for (long long g = m / n; g >= 1; g--) {
    for (long long i = 0; i <= n; i++)
      for (long long j = 0; j <= m / g + 1; j++) f[i][j] = 0;
    for (long long j = 0; j <= m / g + 1; j++) f[0][j] = j + 1;
    for (long long i = 1; i <= n; i++) {
      long long L = (l[i] + g - 1) / g, R = r[i] / g;
      for (long long a = 0; a <= m / g + 1; a++) {
        long long cl = a + L, cr = std::min(a + R, m / g);
        if (cl > cr)
          f[i][a] = 0;
        else
          f[i][a] = (f[i - 1][cr] - (cl ? f[i - 1][cl - 1] : 0) + P) % P;
        if (a > 0) f[i][a] = (f[i][a] + f[i][a - 1]) % P;
      }
    }
    ans[g] = f[n][0];
    for (long long i = 2 * g; i <= m; i += g)
      ans[g] = (ans[g] - ans[i] + P) % P;
  }
  std::cout << ans[1];
}
