#include <bits/stdc++.h>
using namespace std;
const int N = 55;
long long dp[N][2 * N];
long long sum[N][2 * N];
int node[N * 2], tot;
long long inv[N];
const int mod = 998244353;
int l[N], r[N];
int Pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1ll * ans * a % mod;
    a = 1ll * a * a % mod;
    b /= 2;
  }
  return ans;
}
int C(int n, int m) {
  if (n >= mod) return 0;
  long long ans = 1;
  for (int i = n, j = 1; i >= n - m + 1; i--, j++)
    ans = ans * i % mod * inv[j] % mod;
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  int minn = 1e9;
  inv[0] = 1;
  long long mul = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &l[i], &r[i]);
    r[i]++;
    node[++tot] = l[i];
    node[++tot] = r[i];
    inv[i] = Pow(i, mod - 2);
    mul = mul * (r[i] - l[i]) % mod;
  }
  mul = Pow(mul, mod - 2);
  sort(node + 1, node + 1 + tot);
  tot = unique(node + 1, node + 1 + tot) - (node + 1);
  for (int j = 0; j <= tot; j++) sum[0][j] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = tot - 1; j >= 0; j--) {
      if (node[j] < l[i] || node[j] >= r[i]) continue;
      for (int k = i - 1; k >= 0; k--) {
        dp[i][j] =
            (dp[i][j] + 1ll * sum[k][j + 1] *
                            C(node[j + 1] - node[j] - 1 + i - k, i - k) % mod) %
            mod;
        if (node[j] < l[k] || node[j] >= r[k]) break;
        ;
      }
    }
    for (int j = tot - 1; j >= 0; j--)
      sum[i][j] = (sum[i][j + 1] + dp[i][j]) % mod;
  }
  printf("%lld", sum[n][0] * mul % mod);
}
