#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const long long int MOD64 = (long long int)(1e18) + 7;
const int INF = 0x7fffffff;
const long long int INF64 = 0x7fffffffffffffff;
const int N = 55;
int l[N], r[N];
int inv[N];
int x[2 * N];
int dp[N][2 * N];
int fp(int a, int k) {
  if (k < 0) a = fp(a, MOD - 2), k = -k;
  int res = 1;
  while (k) {
    if (k & 1) res = 1LL * res * a % MOD;
    a = 1LL * a * a % MOD;
    k >>= 1;
  }
  return res;
}
int C(int n, int k) {
  int res = inv[k];
  for (int i = int(0); i < int(k); i++) {
    res = 1LL * res * (n - i) % MOD;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  inv[0] = 1;
  for (int i = int(1); i < int(N); i++) {
    inv[i] = 1LL * inv[i - 1] * fp(i, MOD - 2) % MOD;
  }
  int n;
  cin >> n;
  int seg = 0;
  for (int i = int(1); i < int(n + 1); i++) {
    cin >> l[i] >> r[i];
    r[i]++;
    x[++seg] = l[i];
    x[++seg] = r[i];
  }
  sort(x + 1, x + seg + 1);
  seg = unique(x + 1, x + seg + 1) - (x + 1);
  for (int i = int(1); i < int(n + 1); i++) {
    l[i] = lower_bound(x + 1, x + seg + 1, l[i]) - x;
    r[i] = lower_bound(x + 1, x + seg + 1, r[i]) - x;
  }
  for (int i = int(0); i < int(seg + 1); i++) dp[0][i] = 1;
  for (int i = int(1); i < int(n + 1); i++) {
    for (int j = int(l[i]); j < int(r[i]); j++) {
      for (int k = i; k >= 1; k--) {
        if (j < l[k] || j >= r[k]) break;
        int dx = x[j + 1] - x[j], dy = i - (k - 1);
        dp[i][j] =
            (dp[i][j] + 1LL * C(dx + dy - 1, dy) * dp[k - 1][j + 1]) % MOD;
      }
    }
    for (int j = seg - 1; j >= 1; j--)
      dp[i][j] = (dp[i][j] + dp[i][j + 1]) % MOD;
  }
  int res = dp[n][1];
  for (int i = int(1); i < int(n + 1); i++)
    res = (1LL * res * fp(x[r[i]] - x[l[i]], -1)) % MOD;
  cout << res << endl;
  return 0;
}
