#include <bits/stdc++.h>
using namespace std;
const int N = 55;
const int mod = 998244353;
int l[N], r[N], a[N * 2], tot;
long long qpow(long long a, int b) {
  long long res = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) res = res * a % mod;
  return res;
}
long long dp[N][N * 2];
long long C(long long n, long long m) {
  long long res = 1, div = 1;
  for (long long i = m; i > m - n; i--) (res *= i) %= mod;
  for (int i = 1; i <= n; i++) (div *= i) %= mod;
  return res * qpow(div, mod - 2) % mod;
}
int main() {
  int n;
  scanf("%d", &n);
  tot = 0;
  long long div = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l[i], &r[i]);
    r[i]++;
    div = div * (r[i] - l[i]) % mod;
    a[++tot] = l[i];
    a[++tot] = r[i];
  }
  sort(a + 1, a + tot + 1);
  tot = unique(a + 1, a + tot + 1) - a - 1;
  for (int i = 1; i <= n; i++) {
    l[i] = lower_bound(a + 1, a + tot + 1, l[i]) - a;
    r[i] = lower_bound(a + 1, a + tot + 1, r[i]) - a;
  }
  for (int i = 1; i <= tot; 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 > 0; k--) {
        if (j < l[k] || j >= r[k]) break;
        dp[i][j] = (dp[i][j] +
                    dp[k - 1][j + 1] * C(i - k + 1, i - k + a[j + 1] - a[j])) %
                   mod;
      }
    }
    for (int j = tot - 1; j > 0; j--) {
      dp[i][j] = (dp[i][j] + dp[i][j + 1]) % mod;
    }
  }
  long long ans = dp[n][1] * qpow(div, mod - 2) % mod;
  printf("%lld\n", ans);
  return 0;
}
