#include <bits/stdc++.h>
using namespace std;
template <const int &MOD>
struct _m_int {
  int val;
  _m_int(int64_t v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(uint64_t v) {
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(int v) : _m_int(int64_t(v)) {}
  _m_int(unsigned v) : _m_int(uint64_t(v)) {}
  explicit operator int() const { return val; }
  explicit operator unsigned() const { return val; }
  explicit operator int64_t() const { return val; }
  explicit operator uint64_t() const { return val; }
  explicit operator double() const { return val; }
  explicit operator long double() const { return val; }
  _m_int &operator+=(const _m_int &other) {
    val -= MOD - other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  _m_int &operator-=(const _m_int &other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return unsigned(x % m);
    unsigned x_high = unsigned(x >> 32), x_low = unsigned(x);
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  _m_int &operator*=(const _m_int &other) {
    val = fast_mod(uint64_t(val) * other.val);
    return *this;
  }
  _m_int &operator/=(const _m_int &other) { return *this *= other.inv(); }
  friend _m_int operator+(const _m_int &a, const _m_int &b) {
    return _m_int(a) += b;
  }
  friend _m_int operator-(const _m_int &a, const _m_int &b) {
    return _m_int(a) -= b;
  }
  friend _m_int operator*(const _m_int &a, const _m_int &b) {
    return _m_int(a) *= b;
  }
  friend _m_int operator/(const _m_int &a, const _m_int &b) {
    return _m_int(a) /= b;
  }
  _m_int &operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  _m_int &operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }
  _m_int operator++(int) {
    _m_int before = *this;
    ++*this;
    return before;
  }
  _m_int operator--(int) {
    _m_int before = *this;
    --*this;
    return before;
  }
  _m_int operator-() const { return val == 0 ? 0 : MOD - val; }
  friend bool operator==(const _m_int &a, const _m_int &b) {
    return a.val == b.val;
  }
  friend bool operator!=(const _m_int &a, const _m_int &b) {
    return a.val != b.val;
  }
  friend bool operator<(const _m_int &a, const _m_int &b) {
    return a.val < b.val;
  }
  friend bool operator>(const _m_int &a, const _m_int &b) {
    return a.val > b.val;
  }
  friend bool operator<=(const _m_int &a, const _m_int &b) {
    return a.val <= b.val;
  }
  friend bool operator>=(const _m_int &a, const _m_int &b) {
    return a.val >= b.val;
  }
  static const int SAVE_INV = int(1e6) + 5;
  static _m_int save_inv[SAVE_INV];
  static void prepare_inv() {
    for (int64_t p = 2; p * p <= MOD; p += p % 2 + 1) assert(MOD % p != 0);
    save_inv[0] = 0;
    save_inv[1] = 1;
    for (int i = 2; i < SAVE_INV; i++)
      save_inv[i] = save_inv[MOD % i] * (MOD - MOD / i);
  }
  _m_int inv() const {
    if (save_inv[1] == 0) prepare_inv();
    if (val < SAVE_INV) return save_inv[val];
    _m_int product = 1;
    int v = val;
    while (v >= SAVE_INV) {
      product *= MOD - MOD / v;
      v = MOD % v;
    }
    return product * save_inv[v];
  }
  _m_int pow(int64_t p) const {
    if (p < 0) return inv().pow(-p);
    _m_int a = *this, result = 1;
    while (p > 0) {
      if (p & 1) result *= a;
      p >>= 1;
      if (p > 0) a *= a;
    }
    return result;
  }
  friend ostream &operator<<(ostream &os, const _m_int &m) {
    return os << m.val;
  }
};
template <const int &MOD>
_m_int<MOD> _m_int<MOD>::save_inv[_m_int<MOD>::SAVE_INV];
extern const int MOD = 998244353;
using mod_int = _m_int<MOD>;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> last_prime(m + 1, -1);
  for (int i = 2; i <= m; i++) {
    if (last_prime[i] != -1) {
      continue;
    }
    for (int j = i; j <= m; j += i) {
      last_prime[j] = i;
    }
  }
  vector<int> mobius(m + 1);
  mobius[1] = 1;
  for (int i = 2; i <= m; i++) {
    int x = i;
    bool flag = false;
    int cnt = 0;
    while (x > 1) {
      int pr = last_prime[x];
      int cur = 0;
      while (x % pr == 0) {
        x /= pr;
        cur++;
      }
      if (cur > 1) {
        flag = true;
        break;
      }
      cnt++;
    }
    if (flag) {
      continue;
    }
    mobius[i] = (cnt % 2 == 1 ? -1 : 1);
  }
  vector<int> l(n), r(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
  }
  mod_int ans = 0;
  for (int g = 1; g <= m; g++) {
    if (mobius[g] == 0) {
      continue;
    }
    int s = m / g + 1;
    vector<mod_int> dp(s, 0);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
      int nl = (l[i] + g - 1) / g;
      int nr = r[i] / g;
      vector<mod_int> psum(s + 1, 0);
      for (int x = 0; x < s; x++) {
        psum[x + 1] = psum[x] + dp[x];
      }
      vector<mod_int> ndp(s, 0);
      if (nl <= nr) {
        for (int x = 0; x < s; x++) {
          ndp[x] = psum[max(x - nl + 1, 0)] - psum[max(x - nr, 0)];
        }
      }
      ndp.swap(dp);
    }
    mod_int res = 0;
    for (int x = 0; x < s; x++) {
      res += dp[x];
    }
    ans += res * mobius[g];
  }
  cout << ans << '\n';
  return 0;
}

### Prompt

Please create a solution in CPP to the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <const int &MOD>
struct _m_int {
  int val;
  _m_int(int64_t v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(uint64_t v) {
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(int v) : _m_int(int64_t(v)) {}
  _m_int(unsigned v) : _m_int(uint64_t(v)) {}
  explicit operator int() const { return val; }
  explicit operator unsigned() const { return val; }
  explicit operator int64_t() const { return val; }
  explicit operator uint64_t() const { return val; }
  explicit operator double() const { return val; }
  explicit operator long double() const { return val; }
  _m_int &operator+=(const _m_int &other) {
    val -= MOD - other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  _m_int &operator-=(const _m_int &other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return unsigned(x % m);
    unsigned x_high = unsigned(x >> 32), x_low = unsigned(x);
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  _m_int &operator*=(const _m_int &other) {
    val = fast_mod(uint64_t(val) * other.val);
    return *this;
  }
  _m_int &operator/=(const _m_int &other) { return *this *= other.inv(); }
  friend _m_int operator+(const _m_int &a, const _m_int &b) {
    return _m_int(a) += b;
  }
  friend _m_int operator-(const _m_int &a, const _m_int &b) {
    return _m_int(a) -= b;
  }
  friend _m_int operator*(const _m_int &a, const _m_int &b) {
    return _m_int(a) *= b;
  }
  friend _m_int operator/(const _m_int &a, const _m_int &b) {
    return _m_int(a) /= b;
  }
  _m_int &operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  _m_int &operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }
  _m_int operator++(int) {
    _m_int before = *this;
    ++*this;
    return before;
  }
  _m_int operator--(int) {
    _m_int before = *this;
    --*this;
    return before;
  }
  _m_int operator-() const { return val == 0 ? 0 : MOD - val; }
  friend bool operator==(const _m_int &a, const _m_int &b) {
    return a.val == b.val;
  }
  friend bool operator!=(const _m_int &a, const _m_int &b) {
    return a.val != b.val;
  }
  friend bool operator<(const _m_int &a, const _m_int &b) {
    return a.val < b.val;
  }
  friend bool operator>(const _m_int &a, const _m_int &b) {
    return a.val > b.val;
  }
  friend bool operator<=(const _m_int &a, const _m_int &b) {
    return a.val <= b.val;
  }
  friend bool operator>=(const _m_int &a, const _m_int &b) {
    return a.val >= b.val;
  }
  static const int SAVE_INV = int(1e6) + 5;
  static _m_int save_inv[SAVE_INV];
  static void prepare_inv() {
    for (int64_t p = 2; p * p <= MOD; p += p % 2 + 1) assert(MOD % p != 0);
    save_inv[0] = 0;
    save_inv[1] = 1;
    for (int i = 2; i < SAVE_INV; i++)
      save_inv[i] = save_inv[MOD % i] * (MOD - MOD / i);
  }
  _m_int inv() const {
    if (save_inv[1] == 0) prepare_inv();
    if (val < SAVE_INV) return save_inv[val];
    _m_int product = 1;
    int v = val;
    while (v >= SAVE_INV) {
      product *= MOD - MOD / v;
      v = MOD % v;
    }
    return product * save_inv[v];
  }
  _m_int pow(int64_t p) const {
    if (p < 0) return inv().pow(-p);
    _m_int a = *this, result = 1;
    while (p > 0) {
      if (p & 1) result *= a;
      p >>= 1;
      if (p > 0) a *= a;
    }
    return result;
  }
  friend ostream &operator<<(ostream &os, const _m_int &m) {
    return os << m.val;
  }
};
template <const int &MOD>
_m_int<MOD> _m_int<MOD>::save_inv[_m_int<MOD>::SAVE_INV];
extern const int MOD = 998244353;
using mod_int = _m_int<MOD>;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> last_prime(m + 1, -1);
  for (int i = 2; i <= m; i++) {
    if (last_prime[i] != -1) {
      continue;
    }
    for (int j = i; j <= m; j += i) {
      last_prime[j] = i;
    }
  }
  vector<int> mobius(m + 1);
  mobius[1] = 1;
  for (int i = 2; i <= m; i++) {
    int x = i;
    bool flag = false;
    int cnt = 0;
    while (x > 1) {
      int pr = last_prime[x];
      int cur = 0;
      while (x % pr == 0) {
        x /= pr;
        cur++;
      }
      if (cur > 1) {
        flag = true;
        break;
      }
      cnt++;
    }
    if (flag) {
      continue;
    }
    mobius[i] = (cnt % 2 == 1 ? -1 : 1);
  }
  vector<int> l(n), r(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
  }
  mod_int ans = 0;
  for (int g = 1; g <= m; g++) {
    if (mobius[g] == 0) {
      continue;
    }
    int s = m / g + 1;
    vector<mod_int> dp(s, 0);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
      int nl = (l[i] + g - 1) / g;
      int nr = r[i] / g;
      vector<mod_int> psum(s + 1, 0);
      for (int x = 0; x < s; x++) {
        psum[x + 1] = psum[x] + dp[x];
      }
      vector<mod_int> ndp(s, 0);
      if (nl <= nr) {
        for (int x = 0; x < s; x++) {
          ndp[x] = psum[max(x - nl + 1, 0)] - psum[max(x - nr, 0)];
        }
      }
      ndp.swap(dp);
    }
    mod_int res = 0;
    for (int x = 0; x < s; x++) {
      res += dp[x];
    }
    ans += res * mobius[g];
  }
  cout << ans << '\n';
  return 0;
}

```