#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 123;
int dp[maxn][maxn], l[maxn], r[maxn], a[maxn], c[maxn][maxn];
int n, cnt;
int qpow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1ll * a * ans % mod;
    b >>= 1;
    a = 1ll * a * a % mod;
  }
  return ans;
}
int id(int x) { return lower_bound(a, a + cnt, x) - a; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    scanf("%d%d", l + i, r + i), a[cnt++] = l[i], r[i]++, a[cnt++] = r[i];
  sort(a, a + cnt);
  cnt = unique(a, a + cnt) - a;
  a[cnt] = a[cnt - 1] + 1;
  for (int i = 1; i <= n; i++) l[i] = id(l[i]), r[i] = id(r[i]);
  for (int i = 0; i < cnt; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= n; j++) {
      c[i][j] = 1ll * c[i][j - 1] * (j - 1 + a[i + 1] - a[i]) % mod *
                qpow(j, mod - 2) % mod;
    }
  }
  reverse(l + 1, l + n + 1);
  reverse(r + 1, r + n + 1);
  for (int i = 0; i < cnt; i++) dp[0][i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int k = 0; k < cnt; k++) {
      for (int j = i; j <= n; j++) {
        if (l[j] > k || r[j] <= k) break;
        for (int l = k + 1; l < cnt; l++)
          dp[j][l] += 1ll * dp[i - 1][k] * c[k][j - i + 1] % mod,
              dp[j][l] %= mod;
      }
    }
  }
  int ans = dp[n][cnt - 1];
  int base = 1;
  for (int i = 1; i <= n; i++) {
    base = base * 1ll * (a[r[i]] - a[l[i]]) % mod;
  }
  cout << 1ll * ans * qpow(base, mod - 2) % mod;
}
