#include <bits/stdc++.h>
using namespace std;
void read(long long &x) { scanf("%lld", &x); }
void read(long long &x, long long &y) { scanf("%lld%lld", &x, &y); }
void read(long long &x, long long &y, long long &z) {
  scanf("%lld%lld%lld", &x, &y, &z);
}
void print(long long x) { printf("%lld ", x); }
void println(long long x) { printf("%lld\n", x); }
const long long N = 1000;
long long n, l[N], r[N], a[N], d[N][N], sz, res = 1;
map<long long, long long> v;
long long bin(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans *= a, ans %= 998244353;
    a *= a, a %= 998244353;
    n /= 2;
  }
  return ans;
}
long long c(long long n, long long k) {
  long long ans = 1, res = 1;
  if (k < 0 || k > n) return 0;
  k = min(k, n - k);
  for (long long i = n - k + 1; i <= n; i++) ans *= i, ans %= 998244353;
  for (long long i = 1; i <= k; i++) res *= i, res %= 998244353;
  return ans * bin(res, 998244353 - 2) % 998244353;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++)
    cin >> l[i] >> r[i], l[i]--, a[++sz] = l[i], a[++sz] = r[i],
                                 res *= (r[i] - l[i]), res %= 998244353;
  reverse(l + 1, l + n + 1);
  reverse(r + 1, r + n + 1);
  sort(a + 1, a + 2 * n + 1);
  sz = 0;
  for (long long i = 1; i <= 2 * n; i++)
    if (!v.count(a[i])) v[a[i]] = ++sz, a[sz] = a[i];
  for (long long i = 1; i <= sz; i++) d[0][i] = 1;
  for (long long i = 1; i <= n; i++) {
    l[i] = v[l[i]];
    r[i] = v[r[i]];
    if (i > 1) l[i] = max(l[i], l[i - 1]);
  }
  for (long long i = n - 1; i >= 1; i--) r[i] = min(r[i], r[i + 1]);
  for (long long i = 1; i <= n; i++) {
    for (long long j = l[i] + 1; j <= sz; j++) {
      if (j > r[i]) {
        d[i][j] = d[i][j - 1];
        continue;
      }
      if (j > l[i] + 1) d[i][j] = d[i][j - 1];
      for (long long k = 1; k <= i; k++) {
        if (r[i - k + 1] < j) break;
        d[i][j] += d[i - k][j - 1] * c(a[j] - a[j - 1] + k - 1, k);
        d[i][j] %= 998244353;
      }
    }
  }
  cout << d[n][sz] * bin(res, 998244353 - 2) % 998244353;
}
