#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 55;
int n, l[N], r[N], num[2 * N], cnt = 0;
long long dp[N][2 * N], res2 = 1;
bool st[2 * N];
long long POW(long long a, long long n) {
  long long ans = 1;
  a %= mod;
  while (n) {
    if (n & 1) ans = ans * a % mod;
    n >>= 1, a = a * a % mod;
  }
  return ans;
}
long long inv(long long x) { return POW(x, mod - 2); }
long long C(long long n, long long m) {
  if (n < m) return 0;
  long long ans = 1;
  for (long long i = 0; i < m; i++) ans *= (n - i) % mod, ans %= mod;
  for (long long i = 1; i <= m; i++) ans = ans * inv(i) % mod;
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l[i], &r[i]);
    num[++cnt] = l[i], num[++cnt] = ++r[i];
    res2 = res2 * inv(r[i] - l[i]) % mod;
  }
  sort(num + 1, num + 1 + cnt);
  cnt = unique(num + 1, num + 1 + cnt) - num - 1;
  for (int i = 1; i <= cnt; i++) dp[0][i + 1] = 1;
  for (int i = 1; i <= n; i++) {
    l[i] = lower_bound(num + 1, num + 1 + cnt, l[i]) - num;
    r[i] = lower_bound(num + 1, num + 1 + cnt, r[i]) - num;
    for (int j = l[i]; j < r[i]; j++) {
      for (int k = i - 1; k >= 0; k--) {
        if (j >= l[k + 1] && j < r[k + 1])
          dp[i][j] +=
              (dp[k][j + 1] * C(i - k + (num[j + 1] - num[j]) - 1, i - k)) %
              mod,
              dp[i][j] %= mod;
        else
          break;
      }
    }
    for (int j = cnt; j; j--) dp[i][j] = (dp[i][j] + dp[i][j + 1]) % mod;
  }
  printf("%lld\n", dp[n][1] * res2 % mod);
  return 0;
}
