#include <bits/stdc++.h>
const int MOD = 998244353;
int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  if (a < 0) a += MOD;
  return a;
}
void inline_add(int& a, int b) { a = add(a, b); }
int mul(int a, int b) { return a * 1LL * b % MOD; }
int power(int a, int b) {
  int ret = 1;
  for (; b; b >>= 1, a = mul(a, a))
    if (b & 1) ret = mul(ret, a);
  return ret;
}
int inv(int x) { return power(x, MOD - 2); }
int divide(int x, int y) { return mul(x, inv(y)); }
using Poly = std::vector<int>;
void norm(Poly& p) {
  while (p.size() > 1 && p.back() == 0) p.pop_back();
}
Poly operator+(const Poly& a, const Poly& b) {
  Poly c = a;
  c.resize(std::max(a.size(), b.size()), 0);
  for (int i = 0; i < b.size(); ++i) inline_add(c[i], b[i]);
  norm(c);
  return c;
}
Poly operator*(const Poly& a, const Poly& b) {
  (a.size() + b.size() > 0);
  Poly c(a.size() + b.size() - 1);
  for (int i = 0; i < a.size(); ++i)
    for (int j = 0; j < b.size(); ++j) inline_add(c[i + j], mul(a[i], b[j]));
  norm(c);
  return c;
}
Poly interpolate(const std::vector<int>& x, const std::vector<int>& y) {
  (x.size() > 0);
  int n = x.size() - 1;
  std::vector<std::vector<int>> f(n + 1);
  f[0] = y;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= n - 1; ++j)
      f[i].emplace_back(
          divide(add(f[i - 1][j + 1], -f[i - 1][j]), add(x[i + j], -x[j])));
  Poly cur(1, 1);
  Poly ret;
  for (int i = 0; i <= n; ++i) {
    ret = ret + cur * Poly(1, f[i][0]);
    cur = cur * Poly{add(0, -x[i]), 1};
  }
  return ret;
}
int eval(const Poly& a, int x) {
  int ret = 0;
  for (int i = (int)a.size() - 1; i >= 0; --i) ret = add(mul(ret, x), a[i]);
  return ret;
}
Poly sum_from_l(const Poly& a, int l, int n) {
  std::vector<int> x;
  for (int i = 0; i <= n; ++i) x.emplace_back(l + i);
  std::vector<int> y;
  int cur = 0;
  for (int i = 0; i <= n; ++i) {
    inline_add(cur, eval(a, x[i]));
    y.emplace_back(cur);
  }
  return interpolate(x, y);
}
int sum_over_segment(const Poly& a, int l, int r) {
  return eval(sum_from_l(a, l, a.size()), r - 1);
}
int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> l(n), r(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &l[i], &r[i]);
    ++r[i];
  }
  std::reverse(l.begin(), l.end());
  std::reverse(r.begin(), r.end());
  std::vector<int> coord{0, MOD - 1};
  for (int i = 0; i < n; ++i) {
    coord.emplace_back(l[i]);
    coord.emplace_back(r[i]);
  }
  std::sort(coord.begin(), coord.end());
  coord.erase(std::unique(coord.begin(), coord.end()), coord.end());
  std::vector<Poly> cur(coord.size() - 1);
  for (int i = 0; i + 1 < coord.size(); ++i) {
    if (coord[i] >= l[0] && coord[i + 1] <= r[0]) {
      cur[i] = Poly(1, inv(r[0] - l[0]));
    }
  }
  for (int i = 1; i < n; ++i) {
    std::vector<Poly> next(coord.size() - 1);
    int sum = 0;
    for (int j = 0; j + 1 < coord.size(); ++j) {
      next[j] = sum_from_l(cur[j], coord[j], i) + Poly(1, sum);
      inline_add(sum, sum_over_segment(cur[j], coord[j], coord[j + 1]));
    }
    for (int j = 0; j + 1 < coord.size(); ++j) {
      if (coord[j] >= l[i] && coord[j + 1] <= r[i])
        next[j] = next[j] * Poly(1, inv(r[i] - l[i]));
      else
        next[j] = Poly(1, 0);
    }
    cur = next;
  }
  int result = 0;
  for (int i = 0; i + 1 < coord.size(); ++i)
    inline_add(result, sum_over_segment(cur[i], coord[i], coord[i + 1]));
  printf("%d\n", result);
}
