#include <bits/stdc++.h>
using namespace std;
const int N = 810;
const int M = 1100000;
const long long mod = 998244353;
int n, m;
int l[N], r[N];
long long dp[N][N];
long long p[N];
long long len[N], inv[N];
int nl[N], nr[N];
int c[N], nn;
long long ff[N];
long long pow_mod(long long a, long long e) {
  long long res = 1;
  for (; e; a = a * a % mod, e >>= 1)
    if (e & 1) res = res * a % mod;
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &l[i], &r[i]);
    c[++nn] = l[i] - 1;
    c[++nn] = l[i];
    c[++nn] = l[i] + 1;
    c[++nn] = r[i] - 1;
    c[++nn] = r[i];
    c[++nn] = r[i] + 1;
    len[i] = r[i] - l[i] + 1;
    inv[i] = pow_mod(len[i], mod - 2);
  }
  ff[0] = 1;
  for (int i = 1; i <= n; i++) ff[i] = pow_mod(i, mod - 2);
  c[++nn] = 0;
  sort(c + 1, c + 1 + nn);
  m = unique(c + 1, c + 1 + nn) - c - 1;
  for (int i = 1; i < m; i++) p[i] = c[i + 1] - c[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (l[i] == c[j]) {
        nl[i] = j;
        break;
      }
  for (int i = 1; i <= n; i++)
    for (int j = m; j >= 1; j--)
      if (r[i] == c[j]) {
        nr[i] = j;
        break;
      }
  dp[0][m] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 1; j <= m; j++)
      if (dp[i][j])
        for (int k = nl[i + 1]; k <= min(nr[i + 1], j - 1); k++) {
          long long tmp = 1;
          for (int l = i + 1; l <= n; l++) {
            if (k < nl[l] || k > nr[l]) break;
            int num = l - i;
            tmp = tmp * (p[k] + num - 1) % mod;
            tmp = tmp * ff[num] % mod;
            dp[l][k] = (dp[l][k] + dp[i][j] * tmp % mod) % mod;
          }
        }
  long long ans = 0;
  for (int j = 1; j <= m; j++) ans = (ans + dp[n][j]) % mod;
  for (int i = 1; i <= n; i++) ans = ans * inv[i] % mod;
  cout << ans << endl;
  return 0;
}
