#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const int maxn = 1e6 + 10;
const int MAXN = 55;
const long long mod = 998244353;
long long fac[maxn], ifac[maxn];
long long modpow(long long, long long);
long long inv(long long);
long long nck(long long, long long);
void build();
void testlib();
int n, N;
pair<long long, long long> a[MAXN];
long long dp[MAXN][MAXN * MAXN];
vector<long long> v;
long long tot = 1;
long long nck_bign_smallk(long long n, long long k) {
  long long res = 1;
  long long denom = 1;
  for (long long i = 1; i <= k; i++) {
    res *= (n - i + 1);
    res %= mod;
    denom *= i;
    denom %= mod;
  }
  res *= inv(denom);
  res %= mod;
  res += mod;
  res %= mod;
  return res;
}
long long calc(long long x, long long y) {
  return nck_bign_smallk(x + y - 1, x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  build();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
    a[i].second++;
    tot *= (a[i].second - a[i].first);
    tot %= mod;
    v.push_back(a[i].first);
    v.push_back(a[i].second);
  }
  sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
  N = v.size();
  for (int i = 1; i <= n; i++) {
    a[i].first = std::lower_bound(v.begin(), v.end(), a[i].first) - v.begin();
    a[i].second = std::lower_bound(v.begin(), v.end(), a[i].second) - v.begin();
  }
  for (int j = 0; j < N; j++) {
    dp[0][j] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = a[i].first; j < a[i].second; ++j) {
      for (int k = i - 1; k >= 0; --k) {
        dp[i][j] += dp[k][j + 1] * calc(i - k, v[j + 1] - v[j]);
        dp[i][j] %= mod;
        if (a[k].first > j || a[k].second <= j) {
          break;
        }
      }
    }
    for (int j = N - 1; j >= 0; j--) {
      dp[i][j] += dp[i][j + 1];
      dp[i][j] %= mod;
    }
  }
  long long ans = dp[n][0] * inv(tot) % mod;
  cout << ans << endl;
  return 0;
}
long long modpow(long long x, long long y) {
  x %= mod;
  long long res = 1;
  while (y > 0) {
    if (y % 2 == 1) {
      res *= x;
      res %= mod;
    }
    x = x * x;
    x %= mod;
    y = y / 2;
  }
  return res;
}
long long inv(long long x) {
  assert(x != 0);
  return modpow(x, mod - 2);
}
void build() {
  fac[0] = ifac[0] = 1;
  for (int i = 1; i < maxn; i++) {
    fac[i] = fac[i - 1] * i;
    fac[i] %= mod;
    ifac[i] = inv(fac[i]);
    ifac[i] %= mod;
  }
}
long long nck(long long n, long long k) {
  assert(n >= 0 && k >= 0);
  if (k > n) return 0;
  return (((fac[n] * ifac[k]) % mod) * ifac[n - k]) % mod;
}
void testlib() {
  assert(modpow(1, 1) == 1);
  assert(modpow(4, 2) == 16);
  assert(modpow(2, 5) == 32);
  assert(fac[3] == 6);
  assert(nck(4, 2) == 6);
  assert(nck(10, 2) == 45);
}
