#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long fast(long long x, long long p) {
  if (p == 0) return 1;
  if (p == 1) return x;
  if (p % 2 == 0) {
    long long val = fast(x, p / 2);
    return (val * val) % mod;
  }
  if (p % 2 == 1) {
    long long val = fast(x, p - 1);
    return (val * x) % mod;
  }
  return 0;
}
long long rev(long long x) { return fast(x, mod - 2); }
struct seg {
  long long L;
  long long R;
  seg() {}
  seg(long long L, long long R) : L(L), R(R) {}
};
seg cross(seg& A, seg& B) {}
const int N = 120;
bool can[N][N];
long long dp[N][N];
int main() {
  int n;
  cin >> n;
  vector<seg> arr(n);
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    arr[i] = {x, y + 1};
  }
  reverse(arr.begin(), arr.end());
  vector<long long> pool;
  for (auto elem : arr) {
    pool.push_back(elem.L);
    pool.push_back(elem.R);
  }
  sort(pool.begin(), pool.end());
  vector<seg> all;
  for (int i = 1; i < pool.size(); i++) {
    if (pool[i] == pool[i - 1]) continue;
    all.push_back({pool[i - 1], pool[i]});
  }
  int m = all.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i].L <= all[j].L && all[j].R <= arr[i].R) {
        can[i][j] = 1;
      } else
        can[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      long long len = all[j].R - all[j].L;
      long long val = 1;
      dp[i][j + 1] += dp[i][j];
      dp[i][j + 1] %= mod;
      for (int k = 1; k <= n; k++) {
        if (i + k > n) break;
        if (can[i + k - 1][j] == 0) break;
        long long up = len + k - 1;
        long long down = k;
        up *= rev(down);
        up %= mod;
        val *= up;
        val %= mod;
        dp[i + k][j + 1] += dp[i][j] * val % mod;
        dp[i + k][j + 1] %= mod;
      }
    }
  }
  long long X = 1;
  for (int i = 0; i < n; i++) {
    X *= (arr[i].R - arr[i].L);
    X %= mod;
  }
  X = rev(X);
  X *= dp[n][m];
  X %= mod;
  cout << X << endl;
}
