#include <bits/stdc++.h>
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; c > '9' || c < '0'; c = getchar()) {
    if (c == '-') f = -1;
  }
  for (; c >= '0' && c <= '9'; c = getchar()) {
    x = x * 10 + c - '0';
  }
  return x * f;
}
const int mod = 998244353;
long long fac[55], inv[55], facinv[55], dp[55][2005];
int l[55], r[55], tmp[105], cnt;
inline long long q_pow(long long x, int t) {
  long long s = 1;
  for (; t; t >>= 1) {
    if (t & 1) s = s * x % mod;
    x = x * x % mod;
  }
  return s;
}
inline long long C(int x, int y) {
  long long s = facinv[y];
  for (int i = x; i >= x - y + 1; i--) s = s * i % mod;
  return s;
}
inline void work() {
  int n = read();
  long long all = 1;
  fac[0] = 1, facinv[0] = inv[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i % mod;
    l[i] = read(), r[i] = read();
    tmp[++cnt] = l[i];
    tmp[++cnt] = r[i] + 1;
    all = all * (r[i] - l[i] + 1) % mod;
  }
  facinv[n] = q_pow(fac[n], mod - 2);
  inv[n] = facinv[n] * fac[n - 1] % mod;
  for (int i = n - 1; i; i--) {
    facinv[i] = facinv[i + 1] * (i + 1) % mod;
    inv[i] = facinv[i] * fac[i - 1] % mod;
  }
  std::sort(tmp + 1, tmp + cnt + 1);
  cnt = std::unique(tmp + 1, tmp + cnt + 1) - tmp - 1;
  for (int i = 1; i <= n; i++) {
    l[i] = std::lower_bound(tmp + 1, tmp + cnt + 1, l[i]) - tmp;
    r[i] = std::lower_bound(tmp + 1, tmp + cnt + 1, r[i] + 1) - tmp;
  }
  for (int i = 1; i <= cnt; i++) dp[0][i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = l[i]; j < r[i]; j++) {
      for (int k = i; k; k--) {
        if (j < l[k] || j >= r[k]) break;
        dp[i][j] +=
            dp[k - 1][j + 1] * C(i - k + tmp[j + 1] - tmp[j], i - k + 1);
        dp[i][j] %= mod;
      }
    }
    for (int j = cnt - 1; j; j--) dp[i][j] = (dp[i][j] + dp[i][j + 1]) % mod;
  }
  printf("%lld\n", dp[n][1] * q_pow(all, mod - 2) % mod);
}
int main() {
  work();
  return 0;
}
