#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
const int mod = 998244353;
int n, m;
long long de;
int a[maxn], b[maxn], len[maxn << 1], lim[maxn << 1];
long long dp[2][maxn << 1][maxn], sum[maxn << 1], inv[maxn];
inline long long powmod(long long a, long long b) {
  long long res = 1;
  for (; b; b >>= 1) {
    if (b & 1) {
      res = res * a % mod;
    }
    a = a * a % mod;
  }
  return res;
}
inline void init() {
  cin >> n;
  vector<int> has;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    ++b[i];
    has.push_back(a[i]);
    has.push_back(b[i]);
  }
  de = 1;
  for (int i = 1; i <= n; ++i) {
    de *= powmod(b[i] - a[i], mod - 2);
    de %= mod;
  }
  sort(has.begin(), has.end());
  has.erase(unique(has.begin(), has.end()), has.end());
  for (int i = 1; i <= n; ++i) {
    a[i] = lower_bound(has.begin(), has.end(), a[i]) - has.begin() + 1;
    b[i] = lower_bound(has.begin(), has.end(), b[i]) - has.begin() + 1;
  }
  m = has.size();
  for (int i = 1; i <= m - 1; ++i) {
    len[i] = has[i] - has[i - 1];
  }
  inv[1] = 1;
  for (int i = 2; i <= n; ++i) {
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init();
  for (int i = 0; i < m + 5; ++i) {
    sum[i] = 1;
  }
  bool cur = 0;
  for (int i = 1; i <= n; ++i) {
    memset(dp[cur], 0, sizeof(dp[cur]));
    for (int j = a[i]; j < b[i]; ++j) {
      ++lim[j];
      for (int k = lim[j]; k >= 2; --k) {
        dp[cur][j][k] =
            dp[cur ^ 1][j][k - 1] * (len[j] + k - 1) % mod * inv[k] % mod;
      }
      dp[cur][j][1] = sum[j + 1] * len[j] % mod;
    }
    sum[m] = 0;
    for (int j = m - 1; j >= 1; --j) {
      sum[j] = sum[j + 1];
      for (int k = lim[j]; k >= 1; --k) {
        sum[j] += dp[cur][j][k];
        sum[j] %= mod;
      }
    }
    cur ^= 1;
  }
  long long res = sum[1] * de % mod;
  cout << res << '\n';
  return 0;
}
