#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 1e3 + 7, P = 998244353;
long long n, m;
long long f[51][N], g[N], l[51], r[51];
long long get(long long i, long long j) { return j < 0 ? 0 : f[i][j]; }
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) scanf("%lld%lld", &l[i], &r[i]);
  for (long long d = m; d >= 1; d--) {
    long long t = m / d;
    for (long long j = 0; j <= t; j++) f[0][j] = 1;
    for (long long j = 1; j <= n; j++) {
      long long L = (l[j] + d - 1) / d, R = r[j] / d;
      for (long long k = 0; k <= t; k++)
        f[j][k] =
            (f[j][k - 1] + get(j - 1, k - L) - get(j - 1, k - R - 1) + P) % P;
    }
    g[d] = f[n][t];
    for (long long j = 2; j <= t; j++) g[d] = (g[d] - g[j * d] + P) % P;
  }
  printf("%lld\n", g[1]);
}
