#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
const int MOD = 998244353;
long long POW(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n /= 2;
  }
  return res;
}
long long C(long long n, long long m) {
  if (m > n) return 0;
  long long fz = 1, fm = 1;
  for (long long i = n; i >= (n - m + 1); i--) fz = fz * i % MOD;
  for (long long i = 1; i <= m; i++) fm = fm * i % MOD;
  return fz * POW(fm, MOD - 2) % MOD;
}
int L[51], R[51];
vector<long long> v;
void init(int n) {
  v.push_back(-1);
  for (int i = 1; i <= n; i++) {
    v.push_back(L[i]);
    v.push_back(R[i] + 1);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 1; i <= n; i++) {
    R[i] = lower_bound(v.begin(), v.end(), R[i] + 1) - v.begin() - 1;
    L[i] = lower_bound(v.begin(), v.end(), L[i]) - v.begin();
  }
}
long long d[51][110];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d%d", &L[i], &R[i]);
  init(n);
  memset(d, 0, sizeof d);
  for (int i = 0; i < v.size(); i++) d[0][i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = L[i]; j <= R[i]; j++)
      for (int k = i - 1; k >= 0; k--) {
        d[i][j] += d[k][j + 1] * C(v[j + 1] - v[j] + i - k - 1, i - k) % MOD;
        d[i][j] %= MOD;
        if (L[k] > j || R[k] < j) break;
      }
    for (int j = v.size() - 1; j >= 0; j--) d[i][j] += d[i][j + 1] % MOD;
  }
  long long ans = d[n][0];
  for (int i = 1; i <= n; i++)
    ans = ans * POW(v[R[i] + 1] - v[L[i]], MOD - 2) % MOD;
  cout << ans << endl;
  return 0;
}
