#include <bits/stdc++.h>
using namespace std;
const int N = 111, P = 998244353;
int qpow(long long a, int n) {
  long long r = 1;
  for (; n; n >>= 1, a = a * a % P)
    if (n & 1) r = r * a % P;
  return r;
}
int n, a[N], b[N], c[N], dp[N][N], f[N][N], inv[N];
int main() {
  scanf("%d", &n);
  inv[1] = 1;
  for (int i = 2; i <= n; ++i) inv[i] = (long long)inv[P % i] * (P - P / i) % P;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", a + i, b + i);
    c[++*c] = a[i];
    c[++*c] = ++b[i];
  }
  sort(c + 1, c + 1 + *c);
  int tot = unique(c + 1, c + 1 + *c) - c - 2;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= tot; ++j) {
      int l = c[j], r = c[j + 1];
      if (a[i] <= l && r <= b[i])
        f[i][j] = (long long)(r - l) * qpow(b[i] - a[i], P - 2) % P;
    }
  for (int i = tot; i; --i) dp[1][i] = (f[1][i] + dp[1][i + 1]) % P;
  for (int i = 2; i <= n; ++i)
    for (int j = tot; j; --j) {
      int l = c[j], r = c[j + 1];
      if (a[i] <= l && r <= b[i]) {
        dp[i][j] = dp[i - 1][j + 1];
        int q = qpow(r - l, P - 2), p = q, com = r - l;
        for (int k = i - 2; k >= 0; --k) {
          if (a[k + 1] > l || b[k + 1] < r) break;
          p = (long long)p * f[k + 1][j] % P * q % P;
          com = (long long)com * (r - l + i - k - 1) % P * inv[i - k] % P;
          int t = (long long)com * p % P;
          if (!k)
            dp[i][j] = (dp[i][j] + t) % P;
          else
            dp[i][j] = (dp[i][j] + (long long)t * dp[k][j + 1]) % P;
        }
        dp[i][j] = (long long)dp[i][j] * f[i][j] % P;
      }
      dp[i][j] = (dp[i][j] + dp[i][j + 1]) % P;
    }
  printf("%d\n", dp[n][1]);
}
