#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << ' ' << H;
  debug_out(T...);
}
const long long INF = 1e15;
const long long MOD = 998244353;
const int N = 5e1 + 2;
int A[N], B[N], DP[N << 1][N], I[N];
vector<int> X;
int Power(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = 1LL * a * a % MOD)
    if (b & 1) res = 1LL * res * a % MOD;
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  mt19937 Rnd(time(0));
  for (int i = 1; i < N; i++) I[i] = Power(i, MOD - 2);
  int n;
  cin >> n;
  int t = 1;
  for (int i = 1; i <= n; i++) cin >> A[n - i + 1] >> B[n - i + 1];
  for (int i = 1; i <= n; i++) {
    X.push_back(A[i]), X.push_back(++B[i]);
    t = 1LL * t * Power(B[i] - A[i], MOD - 2) % MOD;
  }
  sort(X.begin(), X.end());
  X.resize(unique(X.begin(), X.end()) - X.begin());
  int m = (int)(X.size());
  for (int i = 1; i <= n; i++) {
    A[i] = upper_bound(X.begin(), X.end(), A[i]) - X.begin();
    B[i] = upper_bound(X.begin(), X.end(), B[i]) - X.begin();
  }
  DP[0][0] = 1;
  for (int i = 1; i < m; i++) {
    DP[i][0] = 1;
    for (int j = 1; j <= n; j++) {
      DP[i][j] = DP[i - 1][j];
      if (i < A[j] || B[j] <= i) continue;
      int l = X[i] - X[i - 1], c = 1;
      int p = l;
      for (int k = j - 1; k >= 0; k--) {
        DP[i][j] = (DP[i][j] + 1LL * p * DP[i - 1][k] % MOD) % MOD;
        if (A[k] <= i && i < B[k])
          p = 1LL * p * (l + c) % MOD * I[++c] % MOD;
        else
          break;
      }
    }
  }
  cout << 1LL * DP[m - 1][n] * t % MOD << '\n';
  return 0;
}
