description: Mocha wants to be an astrologer. There are n stars which can be seen in Zhijiang, and the brightness of the i-th star is a_i. 
  
  Mocha considers that these n stars form a constellation, and she uses (a_1,a_2,…,a_n) to show its state. A state is called mathematical if all of the following three conditions are satisfied:
  
    * For all i (1≤ i≤ n), a_i is an integer in the range [l_i, r_i].
    * ∑  _{i=1} ^ n a_i ≤ m.
    * \gcd(a_1,a_2,…,a_n)=1.
  
  
  
  Here, \gcd(a_1,a_2,…,a_n) denotes the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of integers a_1,a_2,…,a_n.
  
  Mocha is wondering how many different mathematical states of this constellation exist. Because the answer may be large, you must find it modulo 998 244 353.
  
  Two states (a_1,a_2,…,a_n) and (b_1,b_2,…,b_n) are considered different if there exists i (1≤ i≤ n) such that a_i ≠ b_i.
  
  Input
  
  The first line contains two integers n and m (2 ≤ n ≤ 50, 1 ≤ m ≤ 10^5) — the number of stars and the upper bound of the sum of the brightness of stars.
  
  Each of the next n lines contains two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ m) — the range of the brightness of the i-th star.
  
  Output
  
  Print a single integer — the number of different mathematical states of this constellation, modulo 998 244 353.
  
  Examples
  
  Input
  
  
  2 4
  1 3
  1 2
  
  
  Output
  
  
  4
  
  Input
  
  
  5 10
  1 10
  1 10
  1 10
  1 10
  1 10
  
  
  Output
  
  
  251
  
  Input
  
  
  5 100
  1 94
  1 96
  1 91
  4 96
  6 97
  
  
  Output
  
  
  47464146
  
  Note
  
  In the first example, there are 4 different mathematical states of this constellation:
  
    * a_1=1, a_2=1.
    * a_1=1, a_2=2.
    * a_1=2, a_2=1.
    * a_1=3, a_2=1.
solution: import java.net.Inet4Address;
  import java.util.*;
  import java.io.*;
  
  public class B {
      static int fact, n, m, mod = 998244353;
      static int memo[][], a[][];
  
      static int memo2[][];
  
      static int dp(int idx, int rem) {
          if (rem < 0)
              return 0;
          if (idx == n)
              return rem >= 0 ? 1 : 0;
  
          if (memo2[idx][rem] != -1)
              return memo2[idx][rem];
          int ans = 0;
          for (int take = Math.max(fact, ((a[idx][0] + fact - 1) / fact) * fact); take <= a[idx][1]; take += fact) {
              ans += dp(idx + 1, rem - take);
              if (ans >= mod)
                  ans -= mod;
          }
          return memo2[idx][rem] = ans;
      }
  
      static int dp(int fact) {
          for (int i = 0; i <= n; i++)
              for (int j = 0; j <= m / fact; j++) {
                  memo[i][j] = i < n ? 0 : 1;
              }
  
          int[] pre = new int[m / fact + 1];
  
          for (int j = 0; j <= m / fact; j++) {
              pre[j] = memo[n][j];
              if (j > 0)
                  pre[j] = (pre[j] + pre[j - 1]) % mod;
          }
  
          for (int i = n - 1; i >= 0; i--) {
              for (int cur = 1; cur <= m / fact; cur++) {
                  int end = cur - Math.max(1, (a[i][0] + fact - 1) / fact);
                  int start = cur - (Math.min(a[i][1] / fact, cur));
  
                  if (end < start)
                      continue;
                  memo[i][cur] += pre[end];
                  if (start - 1 >= 0)
                      memo[i][cur] -= pre[start - 1];
                  memo[i][cur] += mod;
                  memo[i][cur] %= mod;
              }
              for (int j = 0; j <= m / fact; j++) {
                  pre[j] = memo[i][j];
                  if (j > 0)
                      pre[j] = (pre[j] + pre[j - 1]) % mod;
              }
          }
  //        if (dp(0, m) != memo[0][m / fact])
  //            System.err.println(fact);
          return memo[0][m / fact];
      }
  
      public static void main(String[] args) throws IOException {
  
          Scanner sc = new Scanner(System.in);
          PrintWriter pw = new PrintWriter(System.out);
          n = sc.nextInt();
          m = sc.nextInt();
  
          a = new int[n][2];
          for (int i = 0; i < n; i++)
              a[i] = sc.nextIntArr(2);
  
          memo = new int[n + 1][m + 1];
  
          memo2 = new int[n + 1][m + 1];
  
          int[] ans = new int[m + 1];
  
          for (int i = m; i >= 1; i--) {
              fact = i;
  //            for (int[] x : memo2)
  //                Arrays.fill(x, -1);
              ans[i] = dp(i);
  //            ans[i] = dp(0, m);
  
              for (int k = i + i; k <= m; k += i) {
                  ans[i] -= ans[k];
                  ans[i] += mod;
                  ans[i] %= mod;
              }
          }
  //        System.err.println(Arrays.toString(ans));
          pw.println(ans[1]);
  
          pw.flush();
      }
  
  
      static long gcd(long a, long b) {
          if (a == 0)
              return b;
          return gcd(b % a, a);
      }
  
  
      static class Scanner {
          StringTokenizer st;
          BufferedReader br;
  
          public Scanner(FileReader r) {
              br = new BufferedReader(r);
          }
  
          public Scanner(InputStream s) {
              br = new BufferedReader(new InputStreamReader(s));
          }
  
          public String next() throws IOException {
              while (st == null || !st.hasMoreTokens())
                  st = new StringTokenizer(br.readLine());
              return st.nextToken();
          }
  
          public int[] nextIntArr(int n) throws IOException {
              int[] a = new int[n];
              for (int i = 0; i < n; i++) {
                  a[i] = nextInt();
              }
              return a;
          }
  
          public int nextInt() throws IOException {
              return Integer.parseInt(next());
          }
  
          public long nextLong() throws IOException {
              return Long.parseLong(next());
          }
  
          public String nextLine() throws IOException {
              return br.readLine();
          }
  
          public double nextDouble() throws IOException {
              String x = next();
              StringBuilder sb = new StringBuilder("0");
              double res = 0, f = 1;
              boolean dec = false, neg = false;
              int start = 0;
              if (x.charAt(0) == '-') {
                  neg = true;
                  start++;
              }
              for (int i = start; i < x.length(); i++)
                  if (x.charAt(i) == '.') {
                      res = Long.parseLong(sb.toString());
                      sb = new StringBuilder("0");
                      dec = true;
                  } else {
                      sb.append(x.charAt(i));
                      if (dec)
                          f *= 10;
                  }
              res += Long.parseLong(sb.toString()) / f;
              return res * (neg ? -1 : 1);
          }
  
          public boolean ready() throws IOException {
              return br.ready();
          }
      }
  
  }