#include <bits/stdc++.h>
using namespace std;
void Freopen() {
  freopen(
      "title"
      ".in",
      "r", stdin);
  freopen(
      "title"
      ".out",
      "w", stdout);
}
int read() {
  int g = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    g = g * 10 + ch - '0';
    ch = getchar();
  }
  return g * f;
}
const int mod = 998244353;
const int N = 55;
int l[N], r[N], n, a[N << 1], cnt, g[N], f[N], di = 1;
int ksm(int x, int y) {
  int re = 1;
  while (y) {
    if (y & 1) re = 1ll * re * x % mod;
    x = 1ll * x * x % mod;
    y >>= 1;
  }
  return re;
}
signed main() {
  n = read();
  for (int i = (1); i <= (n); i++)
    l[i] = read(), r[i] = read(), a[++cnt] = l[i] - 1, a[++cnt] = r[i],
    di = 1ll * di * (r[i] - l[i] + 1) % mod;
  sort(a + 1, a + cnt + 1);
  cnt = unique(a + 1, a + cnt + 1) - a - 1;
  f[0] = 1;
  for (int j = (cnt); j >= (2); j--) {
    int L = a[j] - a[j - 1];
    g[0] = 1;
    for (int i = (1); i <= (n); i++)
      g[i] = 1ll * g[i - 1] * (i + L - 1) % mod * ksm(i, mod - 2) % mod;
    for (int i = (n); i >= (1); i--)
      if (l[i] <= a[j - 1] + 1 && a[j] <= r[i])
        for (int t = (i - 1); t >= (0); t--) {
          f[i] = (f[i] + 1ll * f[t] * g[i - t] % mod) % mod;
          if (!(l[t] <= a[j - 1] + 1 && a[j] <= r[t])) break;
        }
  }
  return cout << 1ll * f[n] * ksm(di, mod - 2) % mod, signed();
}
