#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
long long inv[10010 + 10], fac[10010 + 10], ifac[10010 + 10];
void setComb() {
  inv[0] = 1;
  inv[1] = 1;
  fac[1] = 1;
  ifac[1] = 1;
  fac[0] = 1;
  ifac[0] = 1;
  for (int i = 2; i < 10010; i++) {
    inv[i] = (-MOD / i) * inv[MOD % i] % MOD;
    fac[i] = fac[i - 1] * i % MOD;
    ifac[i] = ifac[i - 1] * inv[i] % MOD;
    inv[i] = (inv[i] + MOD) % MOD;
    fac[i] = (fac[i] + MOD) % MOD;
    ifac[i] = (ifac[i] + MOD) % MOD;
  }
  return;
}
long long mod_pow(long long x, long long n) {
  x %= MOD;
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
void add(long long &a, long long b) { a = (a + b) % MOD; }
void mul(long long &a, long long b) {
  a %= MOD;
  b %= MOD;
  a = a * b % MOD;
}
long long hcomb(long long n, long long r) {
  if (n == 0 && r == 0)
    return 1;
  else if (n < 0 || r < 0)
    return 0;
  long long res = 1;
  long long m = n + r - 1;
  for (long long i = m; i >= m - r + 1; i--) mul(res, i);
  mul(res, ifac[r]);
  return res;
}
int N;
vector<long long> L, R;
long long dp[55][105];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  L.resize(N);
  R.resize(N);
  for (int i = 0; i < (N); ++i) cin >> L[i] >> R[i];
  setComb();
  reverse(L.begin(), L.end());
  reverse(R.begin(), R.end());
  vector<long long> v;
  for (int i = 0; i < (N); ++i) {
    R[i]++;
    v.push_back(L[i]);
    v.push_back(R[i]);
  }
  v.push_back(-MOD);
  v.push_back(MOD);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  int V = v.size();
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < V; j++) {
      for (int nj = j + 1; nj < V; nj++) {
        long long width = 1;
        if (nj + 1 < V) width = v[nj + 1] - v[nj];
        for (int ni = i; ni < N; ni++) {
          if (L[ni] > v[nj] || R[ni] <= v[nj]) break;
          long long coef = hcomb(width, ni - i + 1);
          long long res = dp[i][j];
          mul(res, coef);
          add(dp[ni + 1][nj], res);
        }
      }
    }
  }
  long long ans = 0;
  for (int j = 0; j < (V); ++j) add(ans, dp[N][j]);
  long long sum = 1;
  for (int i = 0; i < (N); ++i) mul(sum, R[i] - L[i]);
  long long rev = mod_pow(sum, MOD - 2);
  mul(ans, rev);
  cout << ans << endl;
  return 0;
}
