#include <bits/stdc++.h>
using namespace std;
const int maxn = 105, mod = 998244353;
int ls[maxn], dp[maxn][maxn], lsh, l[maxn], r[maxn];
inline int mul(int a, int b) { return 1ll * a * b % mod; }
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int qpow(int a, int b, int c = 1) {
  for (; b; b >>= 1, a = mul(a, a))
    if (b & 1) c = mul(c, a);
  return c;
}
int C(int n, int m) {
  int ans = 1;
  for (int i = n; i >= n - m + 1; --i) ans = mul(ans, i);
  for (int i = 1; i <= m; ++i) ans = mul(ans, qpow(i, mod - 2));
  return ans;
}
int main() {
  int n, ans = 0, inv = 1;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> l[i] >> r[i], l[i], ++r[i], ls[++lsh] = l[i], ls[++lsh] = r[i],
                                       inv = mul(inv, r[i] - l[i]),
                                       cerr << r[i] << endl;
  sort(ls + 1, ls + lsh + 1);
  lsh = unique(ls + 1, ls + lsh + 1) - ls - 1;
  for (int i = 1; i <= n; ++i)
    l[i] = lower_bound(ls + 1, ls + lsh + 1, l[i]) - ls,
    r[i] = lower_bound(ls + 1, ls + lsh + 1, r[i]) - ls;
  dp[0][lsh] = 1;
  r[0] = lsh + 1;
  l[0] = lsh;
  for (int i = 1; i <= n; ++i)
    for (int j = l[i]; j < r[i]; ++j) {
      dp[i][j] = 0;
      for (int k = i; k; --k)
        if (l[k] <= j && j < r[k]) {
          int res = 0;
          for (int p = max(j + 1, l[k - 1]); p < r[k - 1]; ++p)
            res = add(res, dp[k - 1][p]);
          dp[i][j] =
              add(dp[i][j], mul(res, C(ls[j + 1] - ls[j] + i - k, i - k + 1)));
        } else
          break;
    }
  for (int i = l[n]; i < r[n]; ++i) ans = add(ans, dp[n][i]);
  inv = qpow(inv, mod - 2);
  cout << 1ll * ans * inv % mod << endl;
  return 0;
}
