#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9 + 5;
const long long ooll = 1e18;
const int MOD = 998244353;
const int N = 105;
struct Segment {
  int l, r, c;
  vector<int> coeff;
  void disp() {
    cout << l << " " << r << " " << c << " : ";
    for (auto it : coeff) cout << it << " ";
    cout << ";";
  }
};
int inv[N];
void pre() {
  int i;
  inv[1] = 1;
  for (i = 2; i < N; i++) {
    inv[i] = (inv[MOD % i] * 1LL * (MOD - MOD / i)) % MOD;
  }
}
long long powermod(long long a, long long b) {
  if (b == 0) return 1;
  long long res = powermod(a, b / 2);
  res = (res * res) % MOD;
  if (b & 1) res = (res * a) % MOD;
  return res;
}
Segment PartialSum(Segment &s) {
  Segment ans;
  ans.l = s.l;
  ans.r = s.r;
  ans.c = s.c + 1;
  int n = s.coeff.size(), i;
  ans.coeff.resize(n + 1, 0);
  int sub = s.c;
  for (i = 1; i <= n; i++) {
    ans.coeff[i] = s.coeff[i - 1];
    ans.coeff[0] = (ans.coeff[0] - (s.coeff[i - 1] * 1LL * sub) % MOD);
    if (ans.coeff[0] < 0) ans.coeff[0] += MOD;
    sub = ((sub * 1LL * (s.c - i)) % MOD * 1LL * inv[i + 1]) % MOD;
  }
  return ans;
}
int GetTerm(Segment &s, int x) {
  int ans = 0, n = s.coeff.size(), term = 1;
  for (int i = 0; i < n; i++) {
    ans = (ans + (s.coeff[i] * 1LL * term) % MOD);
    if (ans >= MOD) ans -= MOD;
    term = ((term * 1LL * (x + s.c - i)) % MOD * 1LL * inv[i + 1]) % MOD;
  }
  return ans;
}
vector<Segment> Update(vector<Segment> &v, int l, int r) {
  int curl = l, m = v.size(), i, sum = 0;
  vector<Segment> ans;
  for (i = 0; i < m; i++) {
    Segment now = PartialSum(v[i]);
    now.coeff[0] += sum;
    if (now.coeff[0] >= MOD) now.coeff[0] -= MOD;
    if (v[i].r >= curl) {
      now.c += curl - v[i].l;
      now.l = curl;
      curl = v[i].r + 1;
      ans.push_back(now);
    }
    sum = GetTerm(now, now.r - now.l);
  }
  if (curl <= r) {
    Segment now;
    now.l = curl;
    now.r = r;
    now.coeff.clear();
    now.coeff.push_back(sum);
    ans.push_back(now);
  }
  return ans;
}
int L[N], R[N];
void solve() {
  int n, i;
  cin >> n;
  long long prod = 1;
  for (i = n - 1; i >= 0; i--) {
    cin >> L[i] >> R[i];
    prod = (prod * (R[i] - L[i] + 1)) % MOD;
    if (i < n - 1) R[i] = min(R[i], R[i + 1]);
  }
  for (i = 1; i < n; i++) L[i] = max(L[i], L[i - 1]);
  for (i = 0; i < n; i++) {
    if (L[i] > R[i]) {
      cout << "0\n";
      return;
    }
  }
  L[n] = R[n - 1];
  R[n] = R[n - 1];
  vector<Segment> cur;
  Segment first;
  first.l = L[0];
  first.r = R[0];
  first.c = 1;
  first.coeff.push_back(1);
  cur.push_back(first);
  for (i = 1; i <= n; i++) {
    cur = Update(cur, L[i], R[i]);
  }
  prod = powermod(prod, MOD - 2);
  long long ans = (GetTerm(cur[0], 0) * 1LL * prod) % MOD;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pre();
  int t = 1;
  while (t--) solve();
  return 0;
}
