#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n, m, fac[2100], invf[2100], invx[2100], all, cnt, dn;
long long tmp[2010], dp[2010][2010];
bool cmp(long long x, long long y) { return x < y; }
long long pow_mod(long long x, long long y) {
  long long sum = 1;
  while (y) {
    if (y & 1) {
      sum = sum * x % mod;
    }
    x = x * x % mod;
    y >>= 1;
  }
  return sum;
}
void ini_inv(long long n) {
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  invf[n] = pow_mod(fac[n], mod - 2);
  for (long long i = n - 1; i >= 0; i--) invf[i] = invf[i + 1] * (i + 1) % mod;
  for (long long i = 1; i <= n; i++) invx[i] = invf[i] * fac[i - 1] % mod;
}
long long C(long long m, long long n) {
  long long ans = 1;
  for (long long i = n; i >= n - m + 1; i--) ans = ans * i % mod;
  for (long long i = 1; i <= m; i++) ans = ans * invx[i] % mod;
  return ans;
}
struct note {
  long long l, r;
} a[1100];
int main() {
  long long i, j, k;
  ini_inv(1000);
  scanf("%lld", &n);
  all = 1;
  for (i = 1; i <= n; i++) {
    scanf("%lld%lld", &a[i].l, &a[i].r);
    tmp[++cnt] = a[i].l, tmp[++cnt] = a[i].r + 1;
    all = all * (a[i].r - a[i].l + 1) % mod;
  }
  sort(tmp + 1, tmp + cnt + 1, cmp);
  dn = unique(tmp + 1, tmp + cnt + 1) - tmp - 1;
  for (i = 1; i <= n; i++) {
    a[i].l = lower_bound(tmp + 1, tmp + dn + 1, a[i].l) - tmp;
    a[i].r = lower_bound(tmp + 1, tmp + dn + 1, a[i].r + 1) - tmp;
  }
  for (i = 1; i <= dn; i++) dp[0][i] = 1;
  for (i = 1; i <= n; i++) {
    for (j = a[i].l; j < a[i].r; j++) {
      for (k = i; k > 0; k--) {
        if (j < a[k].l || j >= a[k].r) break;
        dp[i][j] +=
            dp[k - 1][j + 1] * C(i - k + 1, i - k + tmp[j + 1] - tmp[j]) % mod;
        dp[i][j] %= mod;
      }
    }
    for (j = dn - 1; j >= 1; j--) {
      dp[i][j] += dp[i][j + 1];
      dp[i][j] %= mod;
    }
  }
  printf("%lld\n", dp[n][1] * pow_mod(all, mod - 2) % mod);
  return 0;
}
