#include <bits/stdc++.h>
using namespace std;
inline int max(int x, int y) { return x > y ? x : y; }
inline int min(int x, int y) { return x < y ? x : y; }
inline int gcd(int n, int m) { return m ? gcd(m, n % m) : n; }
inline int lcm(int x, int y) { return x / gcd(x, y) * y; }
inline void swap(int &x, int &y) {
  int t = x;
  x = y;
  y = t;
  return;
}
namespace yspm {
inline int read() {
  int res = 0, f = 1;
  char k;
  while (!isdigit(k = getchar()))
    if (k == '-') f = -1;
  while (isdigit(k)) res = res * 10 + k - '0', k = getchar();
  return res * f;
}
const int mod = 998244353, N = 2010;
int fac[N], inv[N], ifac[N], b[N], l[N], r[N], n, m, dp[2][N][N], sum[2][N];
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int del(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }
inline int mul(int x, int y) { return 1ll * x * y - 1ll * x * y / mod * mod; }
inline void ckadd(int &x, int y) {
  x = x + y >= mod ? x + y - mod : x + y;
  return;
}
inline int ksm(int x, int y) {
  int res = 1;
  for (; y; y >>= 1, x = mul(x, x))
    if (y & 1) res = mul(res, x);
  return res;
}
vector<int> tr[2][N];
int count, Mult = 1, cur;
signed main() {
  n = read();
  for (register int i = 1; i <= n; ++i)
    l[i] = read(), r[i] = read(), Mult = mul(Mult, r[i] - l[i] + 1),
    b[++m] = r[i] + 1, b[++m] = l[i], b[++m] = r[i];
  sort(b + 1, b + m + 1);
  m = unique(b + 1, b + m + 1) - b - 1;
  for (register int i = 1; i <= n; ++i) {
    l[i] = lower_bound(b + 1, b + m + 1, l[i]) - b;
    r[i] = lower_bound(b + 1, b + m + 1, r[i]) - b;
  }
  inv[0] = inv[1] = 1;
  for (register int i = 2; i <= n; ++i)
    inv[i] = mod - mul(mod / i, inv[mod % i]);
  dp[0][m][0] = 1;
  for (register int i = 1; i <= m; ++i) sum[0][i] = 1;
  for (register int i = 1; i <= n; ++i) {
    cur ^= 1;
    for (register int j = l[i]; j <= r[i]; ++j) {
      ckadd(dp[cur][j][1], mul(b[j + 1] - b[j], sum[cur ^ 1][j + 1]));
      for (auto p : tr[cur ^ 1][j])
        dp[cur][j][p + 1] =
            mul(dp[cur ^ 1][j][p], mul(b[j + 1] - b[j] + p, inv[p + 1]));
    }
    for (register int j = m; j >= 1; --j) {
      for (register int k = 1; k <= i; ++k) {
        dp[cur ^ 1][j][k] = 0;
        if (dp[cur][j][k]) tr[cur][j].push_back(k);
        ckadd(sum[cur][j], dp[cur][j][k]);
      }
      tr[cur ^ 1][j].clear(), sum[cur ^ 1][j] = 0;
      ckadd(sum[cur][j], sum[cur][j + 1]);
    }
  }
  printf("%d\n", mul(ksm(Mult, mod - 2), del(sum[cur][1], sum[cur][m])));
  return 0;
}
}  // namespace yspm
signed main() { return yspm::main(); }
