#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
long long n, mod = 998244353, tp, rr = 1;
long long l[100010], r[100010], p[100010], ll[100010], f[100010];
long long ksm(long long a, long long b) {
  long long tp = a, tot = 1LL;
  while (b) {
    if (b & 1LL) tot = tp * tot % mod;
    tp = tp * tp % mod;
    b >>= 1LL;
  }
  return tot;
}
long long C(long long a, long long b) {
  long long sum = 1, tot = 1;
  for (long long i = 1; i <= b; i++)
    sum = sum * (a - i + 1) % mod, tot = tot * i % mod;
  return sum * ksm(tot, mod - 2) % mod;
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
    p[++tp] = l[i];
    p[++tp] = ++r[i];
    rr = rr * (r[i] - l[i]) % mod;
  }
  sort(p + 1, p + tp + 1);
  for (long long i = 1; i <= tp; i++) ll[i] = p[i + 1] - p[i];
  f[0] = 1;
  l[0] = p[1], r[0] = p[tp];
  for (long long s = tp - 1; s >= 1; s--) {
    if (p[s] == p[s + 1]) continue;
    for (long long i = n; i >= 1; i--) {
      for (long long j = i - 1; j >= 0; j--) {
        if (p[s] < l[j + 1] || p[s + 1] > r[j + 1]) break;
        f[i] += f[j] * C(ll[s] + i - j - 1, i - j) % mod;
        f[i] %= mod;
      }
    }
  }
  cout << f[n] * ksm(rr, mod - 2) % mod;
}
