#include <bits/stdc++.h>
using namespace std;
const int M = 998244353;
long long power(long long a, long long p) {
  if (p == 0) return 1;
  long long ans = power(a, p / 2);
  ans = (ans * ans) % M;
  if (p % 2) ans = (ans * a) % M;
  return ans;
}
long long interpolate(vector<long long> x, vector<long long> y, long long X) {
  int n = x.size();
  assert(y.size() == n);
  assert(n > 0);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long num = 1, denom = 1;
    for (int j = 0; j < n; j++) {
      if (j == i) continue;
      num = (num * (X + M - x[j])) % M;
      denom = (denom * (x[i] + M - x[j])) % M;
    }
    long long ff = (num * power(denom, M - 2)) % M;
    ans = (ans + ff * y[i]) % M;
  }
  for (int i = 0; i < n; i++) {
    long long num = 1, denom = 1;
    for (int j = 0; j < n; j++) {
      if (j == i) continue;
      num = (num * (X + M - x[j])) % M;
      denom = (denom * (x[i] + M - x[j])) % M;
    }
    long long ff = (num * power(denom, M - 2)) % M;
    ans = (ans + ff * y[i]) % M;
  }
  return (ans * power(2, M - 2)) % M;
}
const int KK = 52;
map<long long, long long> mp[KK];
map<long long, vector<long long>> x[KK], y[KK];
vector<long long> vv[KK];
long long l[KK], r[KK];
long long get(int i, long long xx) {
  if (mp[i].count(xx)) return mp[i][xx];
  long long pp = *(upper_bound(vv[i].begin(), vv[i].end(), xx) - 1);
  return mp[i][xx] = interpolate(x[i][pp], y[i][pp], xx);
}
int main() {
  vector<long long> v;
  v.push_back(0);
  v.push_back(M);
  vv[0] = v;
  vector<long long> XX, YY;
  for (int i = 0; i < 1; i++) {
    mp[0][i] = 1;
    XX.push_back(i);
    YY.push_back(1);
  }
  x[0][0] = XX;
  y[0][0] = YY;
  int n;
  cin >> n;
  long long total = 1;
  for (int i = n; i > 0; i--) {
    cin >> l[i] >> r[i];
    l[i]++;
    r[i]++;
    total = (total * (r[i] - l[i] + 1)) % M;
  }
  for (int i = 1; i <= n; i++) {
    int l, r;
    l = ::l[i];
    r = ::r[i];
    v.push_back(l);
    v.push_back(r + 1);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    vv[i] = v;
    for (int j = 0; j + 1 < v.size(); j++) {
      int ll = v[j], rr = v[j + 1];
      vector<long long> xx, yy;
      if (ll < l) {
        for (int k = ll; k <= ll + i && k < rr; k++) {
          mp[i][k] = 0;
          xx.push_back(k);
          yy.push_back(0);
        }
      } else if (ll > r) {
        long long yyy = get(i, ll - 1);
        for (int k = ll; k <= ll + i && k < rr; k++) {
          mp[i][k] = yyy;
          xx.push_back(k);
          yy.push_back(yyy);
        }
      } else {
        for (int k = ll; k <= ll + i && k < rr; k++) {
          xx.push_back(k);
          long long yyy = (get(i, k - 1) + get(i - 1, k)) % M;
          mp[i][k] = yyy;
          yy.push_back(yyy);
        }
      }
      x[i][ll] = xx;
      y[i][ll] = yy;
    }
  }
  long long num = get(n, M - 2);
  cout << (num * power(total, M - 2)) % M << endl;
}
