#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, tn, cnt;
int l[55], r[55], lsh[105], len[105];
long long dp[55][105][55];
unordered_map<int, int> mp[55];
inline long long qpow(long long x, int k, long long r = 1) {
  for (; k; k >>= 1, x = x * x % mod)
    if (k & 1) r = r * x % mod;
  return r;
}
inline long long C(int n, int m, long long ret = 1) {
  if (mp[m].find(n) != mp[m].end()) return mp[m][n];
  for (int i = 1; i <= m; ++i)
    ret = ret * (n - i + 1) % mod * qpow(i, mod - 2) % mod;
  return mp[m][n] = ret;
}
int main() {
  scanf("%d", &n);
  long long s = 1;
  for (int i = 1; i <= n; ++i)
    scanf("%d%d", &l[i], &r[i]), ++r[i], lsh[++cnt] = l[i], lsh[++cnt] = r[i],
                                         s = s * (r[i] - l[i]) % mod;
  sort(lsh + 1, lsh + cnt + 1);
  cnt = unique(lsh + 1, lsh + cnt + 1) - lsh - 1;
  for (int i = 1; i <= n; ++i)
    l[i] = lower_bound(lsh + 1, lsh + cnt + 1, l[i]) - lsh,
    r[i] = lower_bound(lsh + 1, lsh + cnt + 1, r[i]) - lsh;
  for (int i = 1; i < cnt; ++i) len[i] = lsh[i + 1] - lsh[i];
  for (int i = l[1]; i < r[1]; ++i) dp[1][i][1] = 1;
  for (int i = 2; i <= n; ++i) {
    for (int j = l[i]; j < r[i]; ++j) {
      for (int t = 1; t < i; ++t) (dp[i][j][t + 1] += dp[i - 1][j][t]) %= mod;
      for (int k = j + 1; k < cnt; ++k)
        for (int t = 1; t < i; ++t)
          (dp[i][j][1] += dp[i - 1][k][t] * C(len[k] + t - 1, t)) %= mod;
    }
  }
  long long ans = 0;
  for (int i = 1; i < cnt; ++i)
    for (int j = 1; j <= n; ++j)
      (ans += dp[n][i][j] * C(len[i] + j - 1, j)) %= mod;
  return printf("%lld\n", ans * qpow(s, mod - 2) % mod), 0;
}
