#include <bits/stdc++.h>
using namespace std;
const long long inff = 0x3f3f3f3f3f3f3f3f;
const long long N = 110;
const long long mod = 998244353;
const long long inf = 1e15;
const int buffsize = 1e5;
char buf[buffsize], *pp = buf - 1;
int readsize = 0, freadsize = 0;
inline void readinit() {
  fread(buf + (((readsize + buffsize - 1) % buffsize >= buffsize / 2 - 1)
                   ? 0
                   : buffsize / 2),
        1, buffsize / 2, stdin);
  freadsize += buffsize / 2;
}
inline long long read() {
  if (readsize + buffsize / 2 > freadsize) readinit();
  while ((++readsize, *++pp) < '-')
    if (pp == buf + buffsize - 1) pp = buf - 1;
  register long long x = *pp & 15;
  if (pp == buf + buffsize - 1) pp = buf - 1;
  while ((++readsize, *++pp) > '-') {
    x = x * 10 + (*pp & 15);
    if (pp == buf + buffsize - 1) pp = buf - 1;
  }
  if (pp == buf + buffsize - 1) pp = buf - 1;
  return x;
}
long long l[N], r[N], n;
long long b[N], blen;
long long f[N][N][N];
long long p[N];
long long qpow(long long x, long long k, long long mo) {
  long long s = 1;
  while (k) {
    if (k & 1) s = s * x % mo;
    x = x * x % mo;
    k >>= 1;
  }
  return s;
}
long long inv(long long x) { return qpow(x, mod - 2, mod); }
long long C(long long x, long long k) {
  long long s = 1;
  if (k == 0) return 1;
  for (long long i = 1; i <= k; i++) s = s * (x - i + 1) % mod * inv(i) % mod;
  return s;
}
int main() {
  n = read();
  blen = 0;
  for (long long i = 1; i <= n; i++)
    l[i] = read(), r[i] = read(), b[++blen] = l[i], b[++blen] = ++r[i];
  long long fm = 1;
  for (long long i = 1; i <= n; i++) fm = fm * (r[i] - l[i]) % mod;
  sort(b + 1, b + blen + 1);
  blen = unique(b + 1, b + blen + 1) - (b + 1);
  for (long long i = 1; i <= n; i++)
    l[i] = lower_bound(b + 1, b + blen + 1, l[i]) - b,
    r[i] = lower_bound(b + 1, b + blen + 1, r[i]) - b - 1;
  for (long long i = 1; i < blen; i++) p[i] = b[i + 1] - b[i];
  for (long long i = l[1]; i <= r[1]; i++) f[1][i][1] = p[i];
  for (long long i = 2; i <= n; i++)
    for (long long j = l[i]; j <= r[i]; j++)
      for (long long t = 1; t < i; t++)
        for (long long k = r[i - 1]; k >= l[i - 1]; k--) {
          if (k < j) break;
          if (j == k) {
            f[i][j][t + 1] =
                (f[i][j][t + 1] + f[i - 1][k][t] * inv(C(p[j] + t - 1, t)) %
                                      mod * C(p[j] + t, t + 1) % mod) %
                mod;
            break;
          } else {
            f[i][j][1] = (f[i][j][1] + f[i - 1][k][t] * p[j] % mod) % mod;
          }
        }
  long long fz = 0;
  for (long long i = 1; i < blen; i++) {
    for (long long t = 1; t <= n; t++) fz = (fz + f[n][i][t]) % mod;
  }
  return printf("%lld\n", fz * inv(fm) % mod), 0;
}
