#include <bits/stdc++.h>
using namespace std;
inline int read() {
  static char buf[1 << 21], *p1, *p2;
  int f = 0, c = 1;
  char ch =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
           ? EOF
           : *p1++);
  while (ch < '0' || ch > '9') {
    if (ch == '-') c = -1;
    ch =
        (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  while (ch >= '0' && ch <= '9') {
    f = f * 10 + ch - '0';
    ch =
        (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  return c * f;
}
const int M = 520, mod = 998244353;
int f[M], c[M], s[M], l[M], r[M], inv[M], g[M];
int n, m, t, ans, tot = 1;
int ksm(int a, int x) {
  int ans = 1;
  for (; x; x >>= 1, a = 1ll * a * a % mod)
    if (x & 1) ans = 1ll * a * ans % mod;
  return ans;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    s[++t] = l[i] = read();
    s[++t] = r[i] = read() + 1;
    tot = 1ll * tot * (r[i] - l[i]) % mod;
  }
  sort(s + 1, s + t + 1);
  t = unique(s + 1, s + t + 1) - s - 1;
  for (int i = 1; i <= n; ++i) {
    l[i] = lower_bound(s + 1, s + t + 1, l[i]) - s;
    r[i] = lower_bound(s + 1, s + t + 1, r[i]) - s;
  }
  for (int i = 1; i <= n; ++i) inv[i] = ksm(i, mod - 2);
  f[0] = g[0] = 1;
  for (int j = t - 1; j; --j) {
    int k = s[j + 1] - s[j];
    for (int i = 1; i <= n; ++i)
      g[i] = 1ll * g[i - 1] * inv[i] % mod * (k + i - 1) % mod;
    for (int i = n; i; --i) {
      if (l[i] > j || r[i] <= j) continue;
      for (int lst = i - 1; lst >= 0; --lst) {
        f[i] = (f[i] + 1ll * f[lst] * g[i - lst]) % mod;
        if (l[lst] > j || r[lst] <= j) break;
      }
    }
  }
  cout << 1ll * f[n] * ksm(tot, mod - 2) % mod;
  return 0;
}
