#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int add(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
int p[2][100001];
int get(int i, int l, int r) {
  if (r < 0) return 0;
  l = max(l, 0);
  return add(p[i][r], mod - (l == 0 ? 0 : p[i][l - 1]));
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> f(m + 1);
  vector<int> l(n), r(n);
  for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
  for (int d = 1; d <= m; d++) {
    vector<int> L(n), R(n);
    bool fail = false;
    for (int i = 0; i < n; i++) {
      L[i] = (l[i] + d - 1) / d;
      R[i] = r[i] / d;
      if (R[i] < L[i]) fail = true;
    }
    if (fail) continue;
    int bound = m / d;
    for (int i = 0; i <= 1; i++)
      for (int j = 0; j <= bound; j++) p[i][j] = 0;
    p[0][0] = 1;
    for (int i = 1; i <= bound; i++) p[0][i] = 1;
    int cur = 0, nxt = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= bound; j++)
        p[nxt][j] = add(p[nxt][j], get(cur, j - R[i], j - L[i]));
      for (int j = 1; j <= bound; j++)
        p[nxt][j] = add(p[nxt][j], p[nxt][j - 1]);
      for (int j = 0; j <= bound; j++) p[cur][j] = 0;
      swap(cur, nxt);
    }
    f[d] = p[cur][bound];
  }
  for (int i = m; i >= 1; i--) {
    for (int j = i + i; j <= m; j += i) f[i] = add(f[i], mod - f[j]);
  }
  cout << f[1];
}
