#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int N = 110;
long long power(long long base, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * base % mod;
    base = base * base % mod;
    b >>= 1;
  }
  return ret;
}
int n, l[N], r[N], d[N], tot;
long long f[N], g[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &l[i], &r[i]);
    ++r[i];
    d[++tot] = l[i], d[++tot] = r[i];
  }
  sort(d + 1, d + tot + 1);
  tot = unique(d + 1, d + tot + 1) - d - 1;
  for (int i = 1; i <= n; ++i) {
    l[i] = lower_bound(d + 1, d + tot + 1, l[i]) - d;
    r[i] = lower_bound(d + 1, d + tot + 1, r[i]) - d;
  }
  f[0] = 1;
  for (int i = tot - 1; i >= 1; --i) {
    int len = d[i + 1] - d[i];
    g[0] = 1;
    for (int j = 1; j <= n; ++j) {
      g[j] = g[j - 1] * (len + j - 1) % mod * power(j, mod - 2) % mod;
    }
    for (int j = n; j >= 1; --j) {
      if (l[j] <= i && i < r[j]) {
        for (int c = 1, k = j - 1; ~k; --k, ++c) {
          f[j] = (f[j] + g[c] * f[k] % mod) % mod;
          if (i < l[k] || i >= r[k]) break;
        }
      }
    }
  }
  long long ans = f[n];
  for (int i = 1; i <= n; ++i) {
    ans = ans * power(d[r[i]] - d[l[i]], mod - 2) % mod;
  }
  printf("%lld\n", (ans + mod) % mod);
  return 0;
}
