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 sys
  import math
  from collections import deque,Counter
  from sys import stdin
  
  #sys.setrecursionlimit(10**7)
  int1=lambda x: int(x)-1
  
  inp=lambda :int(input())
  mi=lambda :map(int,input().split())
  li=lambda :list(mi())
  mi1=lambda :map(int1,input().split())
  li1=lambda :list(mi1())
  mis=lambda :map(str,input().split())
  lis=lambda :list(mis())
  
  stinput=lambda :stdin.readline()[:-1]
  stinp=lambda :int(stinput())
  stmi=lambda :map(int, stdin.readline().split())
  stli=lambda :list(stmi())
  stmi1=lambda :map(int1, stdin.readline().split())
  stli1=lambda :list(stmi1())
  stmis=lambda :stdin.readline()[:-1]
  
  pr=print
  
  from collections import defaultdict
  """
  #初期値 0
  d=defaultdict(int)
  
  #初期値 1
  d=defaultdict(lambda:1)
  """
  
  mod=10**9+7
  Mod=998244353
  INF=10**18
  ans=0
  
  n,m=mi()
  x=[]
  for i in range(n):
    a,b=mi()
    x.append((a,b))
  
  def f(k):
    dp=[0]*(m//k+1)
    t=m//k+1
    if t<n:
      return 0
    dp[0]=1
    for a,b in x:
      dp2=[0]*t
      c=(a+k-1)//k
      d=b//k
      cnt=0
      if c>d:
        return 0
      for i in range(c,t):
        cnt+=dp[i-c]
        if i>d:
          cnt-=dp[i-d-1]
        cnt%=Mod
        dp2[i]=cnt
      dp=dp2.copy()
    #print(m,dp)
    return sum(dp)%Mod
  
  tmp=[0]*(m+1)
  for i in range(m,0,-1):
    t=f(i)
    j=2*i
    while j<=m:
      t-=tmp[j]
      j+=i
    tmp[i]=t%Mod
  print(tmp[1]%Mod)