#include <bits/stdc++.h>
using namespace std;
const int maxn = 205;
long long cc[200];
int num = 0;
int n;
long long l[55], r[55];
const long long mod = 998244353;
long long dp[200][200];
long long f[200][200];
long long fac[maxn], ifac[maxn], inv[maxn];
long long qm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
long long Choose(long long a, long long b) {
  long long res = 1;
  for (long long i = a; i < b + a; ++i) res = i % mod * res % mod;
  for (long long i = 2; i <= b; ++i) res = res * inv[i] % mod;
  return res;
}
int main() {
  fac[0] = ifac[0] = 1;
  for (int i = 1; i < maxn; ++i)
    fac[i] = fac[i - 1] * i % mod, ifac[i] = qm(fac[i], mod - 2),
    inv[i] = qm(i, mod - 2);
  cin >> n;
  long long fm = 1;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld%lld", &l[i], &r[i]);
    fm = fm * (r[i] - l[i] + 1) % mod;
  }
  reverse(l + 1, l + 1 + n);
  reverse(r + 1, r + 1 + n);
  for (int i = 1; i <= n; ++i) {
    l[i] = max(l[i], l[i - 1]);
    cc[++num] = l[i];
  }
  cc[++num] = r[n] + 1;
  for (int i = n - 1; i >= 1; --i) {
    r[i] = min(r[i], r[i + 1]);
    cc[++num] = r[i] + 1;
  }
  sort(cc + 1, cc + 1 + num);
  num = unique(cc + 1, cc + 1 + num) - cc - 1;
  long long inv2 = (mod + 1) / 2;
  f[0][0] = 1;
  for (int i = 1; i < num; ++i) {
    f[i][0] = 1;
    long long L = cc[i], R = cc[i + 1] - 1;
    for (int j = 1; j <= n; ++j) {
      f[i][j] = f[i - 1][j];
      for (int k = j; k > 0; --k) {
        if (l[k] <= L && R <= r[k]) {
          f[i][j] =
              (f[i][j] + f[i - 1][k - 1] * Choose(R - L + 1, j - k + 1) % mod) %
              mod;
        } else
          break;
      }
    }
  }
  long long ans = f[num - 1][n];
  ans = ans * qm(fm, mod - 2) % mod;
  cout << ans << endl;
}
