#include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
const int MOD = 998244353;
long long modpow(long long x, long long p) {
  if (p == 0) return 1;
  if (p % 2 == 1) return x * modpow(x, p - 1) % MOD;
  long long r = modpow(x, p / 2);
  return r * r % MOD;
}
long long modinv(long long x) { return modpow(x, MOD - 2); }
int n, l[MAXN], r[MAXN], x[MAXN], y[MAXN];
long long dp[MAXN][2 * MAXN], inv[MAXN];
long long cnt(long long s, int n) {
  s += n;
  long long ret = 1;
  for (int i = 1; i <= n; i++) ret = ret * (s - i + 1) % MOD * inv[i] % MOD;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d %d", &l[n - i - 1], &r[n - i - 1]);
  vector<int> vx;
  for (int i = 0; i < n; i++) {
    vx.push_back(l[i]);
    vx.push_back(r[i] + 1);
  }
  sort(vx.begin(), vx.end());
  vx.resize(unique(vx.begin(), vx.end()) - vx.begin());
  long long denom = 1;
  for (int i = 0; i < n; i++) {
    x[i] = lower_bound(vx.begin(), vx.end(), l[i]) - vx.begin();
    y[i] = lower_bound(vx.begin(), vx.end(), r[i] + 1) - vx.begin();
    denom = denom * (r[i] - l[i] + 1) % MOD;
  }
  denom = modinv(denom);
  for (int i = 1; i <= n; i++) inv[i] = modinv(i);
  for (int i = n; i >= 0; i--)
    for (int j = (int)vx.size(); j >= 0; j--) {
      if (i == n) {
        dp[i][j] = 1;
      } else {
        if (j == (int)vx.size()) {
          dp[i][j] = 0;
          continue;
        }
        dp[i][j] = dp[i][j + 1];
        for (int k = i; k < n; k++) {
          if (j < x[k] || j >= y[k]) break;
          dp[i][j] = (dp[i][j] + cnt(vx[j + 1] - vx[j] - 1, k - i + 1) *
                                     dp[k + 1][j + 1]) %
                     MOD;
        }
      }
    }
  printf("%lld\n", dp[0][0] * denom % MOD);
  return 0;
}
