#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
inline int read() {
  int x = 0, neg = 1;
  char op = getchar();
  while (!isdigit(op)) {
    if (op == '-') neg = -1;
    op = getchar();
  }
  while (isdigit(op)) {
    x = 10 * x + op - '0';
    op = getchar();
  }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
const long long mod = 998244353;
const int N = 2000005;
long long inv[N], C[N];
long long f[N], g[N];
int t[N], tot;
int a[N], b[N], n;
long long tots = 1;
long long qpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  n = read();
  inv[1] = 1;
  for (register int i = 2; i <= n; i++)
    inv[i] = inv[mod % i] * (mod - mod / i) % mod;
  for (register int i = 1; i <= n; i++) {
    a[i] = read(), b[i] = read() + 1;
    t[++tot] = a[i], t[++tot] = b[i];
    tots = tots * (long long)(b[i] - a[i]) % mod;
  }
  sort(t + 1, t + tot + 1);
  tot = unique(t + 1, t + tot + 1) - (t + 1);
  for (register int i = 1; i <= n; i++) {
    a[i] = lower_bound(t + 1, t + tot + 1, a[i]) - t;
    b[i] = lower_bound(t + 1, t + tot + 1, b[i]) - t;
  }
  g[0] = 1;
  for (register int j = tot - 1; j >= 1; j--) {
    int len = t[j + 1] - t[j];
    C[0] = 1;
    for (register int i = 1; i <= n; i++) {
      C[i] = C[i - 1] * (len + i - 1) % mod * inv[i] % mod;
    }
    for (register int i = n; i >= 1; i--)
      if (a[i] <= j && j < b[i]) {
        f[i] = 0ll;
        int m = 1;
        for (register int p = i - 1; p >= 0; p--) {
          f[i] = (f[i] + C[m] * g[p] % mod) % mod;
          if (a[p] <= j && j < b[p])
            m++;
          else
            break;
        }
        g[i] = (g[i] + f[i]) % mod;
      }
  }
  long long ans = g[n] % mod;
  ans = ans * qpow(tots, mod - 2) % mod;
  printf("%lld\n", ans);
  return 0;
}
