#include <bits/stdc++.h>
using namespace std;
const int N = 55;
const int MOD = 998244353;
template <typename T>
inline void read(T &AKNOI) {
  T x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  AKNOI = flag * x;
}
namespace ModCalculator {
inline void Inc(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
inline void Dec(int &x, int y) {
  x -= y;
  if (x < 0) x += MOD;
}
inline int Mul(int x, int y) { return 1LL * x * y % MOD; }
}  // namespace ModCalculator
using namespace ModCalculator;
inline int ksm(int x, int k) {
  int ret = 1;
  for (; k; k >>= 1) {
    if (k & 1) ret = Mul(ret, x);
    x = Mul(x, x);
  }
  return ret;
}
inline int inv(int x) { return ksm(x, MOD - 2); }
inline int C(int x, int y) {
  int ret = 1;
  for (int i = 1; i <= y; ++i) {
    ret = Mul(ret, Mul(x + y - i, inv(i)));
  }
  return ret;
}
int n, l[N], r[N], a[N << 1], m;
int dp[N][N << 1], all;
void init() {
  read(n);
  all = 1;
  for (int i = 1; i <= n; ++i) {
    read(l[i]);
    read(r[i]);
    ++r[i];
    a[++m] = l[i];
    a[++m] = r[i];
    all = Mul(all, r[i] - l[i]);
  }
  sort(a + 1, a + m + 1);
  m = unique(a + 1, a + m + 1) - (a + 1);
  for (int i = 1; i <= n; ++i) {
    l[i] = lower_bound(a + 1, a + m + 1, l[i]) - a;
    r[i] = lower_bound(a + 1, a + m + 1, r[i]) - a;
  }
}
void solve() {
  dp[0][m + 1] = 1;
  for (int i = 0; i <= n; ++i) {
    for (int j = m; j >= 1; --j) {
      Inc(dp[i][j], dp[i][j + 1]);
    }
    if (i == n) break;
    for (int j = l[i + 1]; j < r[i + 1]; ++j) {
      int len = a[j + 1] - a[j];
      for (int k = i + 1; k <= n; ++k) {
        if (l[k] > j || r[k] <= j) break;
        Inc(dp[k][j], Mul(dp[i][j + 1], C(len, k - i)));
      }
    }
  }
  printf("%d\n", Mul(dp[n][1], inv(all)));
}
int main() {
  init();
  solve();
  return 0;
}
