#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const long long p = 998244353;
const long long inv2 = 116195171;
long long a[200], l[100], r[100];
long long f[200], inv[200];
long long dp[100][200];
long long pow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % p;
    x = x * x % p, y >>= 1;
  }
  return res;
}
void init() {
  f[0] = 1;
  for (int i = 1; i < 200; i++) f[i] = f[i - 1] * i % p;
  inv[199] = pow(f[199], p - 2);
  for (int i = 198; i >= 1; i--) inv[i] = inv[i + 1] * (i + 1) % p;
}
long long C(long long m, long long n) {
  long long ans = 1;
  for (int i = 1; i <= m; i++, n--) ans = ans * n % p;
  return ans * inv[m] % p;
}
int main() {
  init();
  long long n, op = 0, len = 0, sum = 1;
  scanf("%lld", &n);
  for (int i = n; i >= 1; i--)
    scanf("%lld%lld", &l[i], &r[i]), a[++len] = l[i], a[++len] = ++r[i],
                                     sum = sum * (r[i] - l[i]) % p;
  sort(a + 1, a + 1 + len);
  len = unique(a + 1, a + 1 + len) - a - 1;
  for (int i = 1; i <= n; i++) {
    l[i] = lower_bound(a + 1, a + 1 + len, l[i]) - a;
    r[i] = lower_bound(a + 1, a + 1 + len, r[i]) - a - 1;
  }
  for (long long i = 0; i < len; i++) dp[0][i] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = l[i]; j <= r[i]; j++) {
      for (long long k = i; k >= 1; k--) {
        if (l[k] > j || r[k] < j) break;
        dp[i][j] = (dp[i][j] +
                    dp[k - 1][j - 1] * C(i - k + 1, i - k + a[j + 1] - a[j])) %
                   p;
      }
    }
    for (int j = 1; j < len; j++) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % p;
  }
  sum = dp[n][len - 1] * pow(sum, p - 2) % p;
  cout << sum << endl;
}
