#include <bits/stdc++.h>
using namespace std;
namespace io {
const int SI = 1 << 21 | 1;
char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
int f, t;
inline void flush() { fwrite(OB, 1, OS - OB, stdout), OS = OB; }
inline void pc(char x) {
  *OS++ = x;
  if (OS == OT) flush();
}
template <class I>
inline void rd(I &x) {
  for (f = 1, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                              IS == IT ? EOF : *IS++)
                            : *IS++);
       c < '0' || c > '9';
       c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++))
    if (c == '-') f = -1;
  for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15),
      c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                      IS == IT ? EOF : *IS++)
                    : *IS++))
    ;
  x *= f;
}
inline void rds(char *s, int &x) {
  for (c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++);
       c < 33 || c > 126;
       c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++))
    ;
  for (x = 0; c >= 33 && c <= 126;
       s[++x] = c, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                                   IS == IT ? EOF : *IS++)
                                 : *IS++))
    ;
  s[x + 1] = '\0';
}
template <class I>
inline void print(I x, char k = '\n') {
  if (!x) pc('0');
  if (x < 0) pc('-'), x = -x;
  while (x) ch[++t] = x % 10 + '0', x /= 10;
  while (t) pc(ch[t--]);
  pc(k);
}
inline void prints(string s) {
  int x = s.length();
  while (t < x) pc(s[t++]);
  pc('\n'), t = 0;
}
struct Flush {
  ~Flush() { flush(); }
} flusher;
}  // namespace io
using io::print;
using io::prints;
using io::rd;
using io::rds;
const int P = 998244353;
struct modint {
  int x;
  inline modint(int x = 0) : x(x) {}
  inline modint &operator=(int o) { return x = o, *this; }
  inline modint &operator+=(modint o) {
    return x = x + o.x >= P ? x + o.x - P : x + o.x, *this;
  }
  inline modint &operator-=(modint o) {
    return x = x - o.x < 0 ? x - o.x + P : x - o.x, *this;
  }
  inline modint &operator*=(modint o) { return x = 1ll * x * o.x % P, *this; }
  inline modint &operator^=(long long b) {
    modint a = *this, c;
    if (!~b) b = P - 2;
    c.x = 1 % P;
    while (b) {
      if (b & 1) c *= a;
      a *= a, b >>= 1;
    }
    return x = c.x, *this;
  }
  inline modint &operator/=(modint o) { return *this *= o ^= -1; }
  inline modint &operator+=(int o) {
    return x = x + o >= P ? x + o - P : x + o, *this;
  }
  inline modint &operator-=(int o) {
    return x = x - o < 0 ? x - o + P : x - o, *this;
  }
  inline modint &operator*=(int o) { return x = 1ll * x * o % P, *this; }
  inline modint &operator/=(int o) {
    modint y = modint(o);
    return *this *= y ^= -1;
  }
  template <class I>
  inline friend modint operator+(modint a, I b) {
    return a += b;
  }
  template <class I>
  inline friend modint operator-(modint a, I b) {
    return a -= b;
  }
  template <class I>
  inline friend modint operator*(modint a, I b) {
    return a *= b;
  }
  inline friend modint operator^(modint a, long long b) { return a ^= b; }
  template <class I>
  inline friend modint operator/(modint a, I b) {
    return a /= b;
  }
  inline friend bool operator==(modint a, int b) { return a.x == b; }
  inline friend bool operator!=(modint a, int b) { return a.x != b; }
  inline friend bool operator==(modint a, modint b) { return a.x == b.x; }
  inline friend bool operator!=(modint a, modint b) { return a.x != b.x; }
  inline bool operator!() { return !x; }
  inline modint operator-() { return x ? P - x : 0; }
};
inline void rd(modint &x) { rd(x.x); }
inline void print(modint x, char k = '\n') { print(x.x, k); }
const int N = 507;
int n, a[N], b[N], c[N * 2], t;
modint f[N], g[N], ans;
int main() {
  rd(n);
  for (int i = 1; i <= n; i++)
    rd(a[i]), rd(b[i]), c[++t] = a[i], c[++t] = ++b[i];
  sort(c + 1, c + t + 1), t = unique(c + 1, c + t + 1) - (c + 1);
  for (int i = 1; i <= n; i++)
    a[i] = lower_bound(c + 1, c + t + 1, a[i]) - c,
    b[i] = lower_bound(c + 1, c + t + 1, b[i]) - c;
  f[0] = 1;
  for (int j = t - 1; j; j--) {
    int l = c[j + 1] - c[j];
    g[0] = 1;
    for (int i = 1; i <= n; i++) g[i] = g[i - 1] * (l + i - 1) / i;
    for (int i = n; i; i--)
      if (a[i] <= j && j < b[i])
        for (int c = 1, k = i - 1; ~k; k--, ++c) {
          f[i] += g[c] * f[k];
          if (a[k] > j || j >= b[k]) break;
        }
  }
  ans = f[n];
  for (int i = 1; i <= n; i++) ans /= c[b[i]] - c[a[i]];
  print(ans);
  return 0;
}
