#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
int mxn11 = 2e5 + 1;
vector<long long> t(4 * mxn11 + 1, 0);
vector<long long> tAdd(4 * mxn11 + 1, 0);
void build(int v, int vl, int vr) {
  if (vl == vr) {
  } else {
    int tmp = (vl + vr) >> 1;
    build(2 * v, vl, tmp);
    build(2 * v + 1, tmp + 1, vr);
    t[v] = min(t[2 * v], t[2 * v + 1]);
  }
}
void push(int v) {
  tAdd[2 * v] += tAdd[v];
  tAdd[2 * v + 1] += tAdd[v];
  t[v] += tAdd[v];
  tAdd[v] = 0;
}
long long get(int v, int vl, int vr, int l, int r) {
  if (l > r) return 0;
  if (vl == l && vr == r) {
    return t[v] + tAdd[v];
  }
  int tmp = (vl + vr) >> 1;
  push(v);
  long long a = get(2 * v, vl, tmp, l, min(tmp, r));
  long long b = get(2 * v + 1, tmp + 1, vr, max(tmp + 1, l), r);
  return min(a, b);
}
void update(int v, int vl, int vr, int l, int r, long long cnt) {
  if (l > r) return;
  if (vl == l && vr == r) {
    tAdd[v] += cnt;
    return;
  }
  int tmp = (vl + vr) >> 1;
  push(v);
  update(2 * v, vl, tmp, l, min(tmp, r), cnt);
  update(2 * v + 1, tmp + 1, vr, max(tmp + 1, l), r, cnt);
  t[v] = min(t[2 * v] + tAdd[2 * v], t[2 * v + 1] + tAdd[2 * v + 1]);
}
inline long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long pwm(long long xx, long long pow, long long MD) {
  if (pow < 0) {
    pow = pow % (MD - 1) + MD - 1;
  }
  long long mlt = 1;
  while (pow) {
    if (pow & 1) {
      mlt *= xx;
      mlt %= MD;
    }
    xx *= xx;
    pow >>= 1;
    xx %= MD;
  }
  return mlt;
}
inline long long gcdex(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long xx, yy;
  long long gc = gcdex(b, a % b, yy, xx);
  x = xx;
  y = yy - (a / b) * xx;
  return gc;
}
inline int inv(long long r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }
inline int64_t hilbertOrder(int x, int y, int pow, int rotate) {
  if (pow == 0) {
    return 0;
  }
  int hpow = 1 << (pow - 1);
  int seg = (x < hpow) ? ((y < hpow) ? 0 : 3) : ((y < hpow) ? 1 : 2);
  seg = (seg + rotate) & 3;
  const int rotateDelta[4] = {3, 0, 0, 1};
  int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
  int nrot = (rotate + rotateDelta[seg]) & 3;
  int64_t subSquareSize = int64_t(1) << (2 * pow - 2);
  int64_t ans = seg * subSquareSize;
  int64_t add = hilbertOrder(nx, ny, pow - 1, nrot);
  ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
  return ans;
}
long long mod = 998244353;
vector<long long> x;
vector<long long> y;
vector<long long> kek1;
vector<long long> kek2;
vector<pair<long long, long long> > segs1;
vector<pair<long long, long long> > segs;
long long dp[1000][1000];
bool ismine(int i, int j, int otr) {
  bool kek = true;
  i--;
  j--;
  for (int s = i; s <= j; s++) {
    kek &= segs[otr].first >= x[s] && segs[otr].second <= y[s];
  }
  return kek;
}
long long cnk(long long m, long long n) {
  long long fact = 1;
  for (int i = 2; i <= n; i++) {
    fact *= i;
    fact %= mod;
  }
  long long up = 1;
  for (long long z = m; z <= n + m - 1; z++) {
    up *= z;
    up %= mod;
  }
  return (inv(fact, mod) * up) % mod;
}
void solve() {
  int n;
  cin >> n;
  x.resize(n);
  y.resize(n);
  for (int i = 0; (i) < (n); (i)++) {
    cin >> x[i] >> y[i];
    kek1.push_back(x[i]);
    kek1.push_back(y[i]);
  }
  sort(kek1.begin(), kek1.end());
  long long last = -1;
  int type = 1;
  for (int i = 0; i < kek1.size(); i++) {
    if (kek1[i] != last) {
      last = kek1[i];
      kek2.push_back(last);
      type = 1;
    } else if (type == 1) {
      kek2.push_back(last);
      type++;
    }
  }
  int m = kek2.size() - 1;
  reverse(x.begin(), x.end());
  reverse(y.begin(), y.end());
  for (int i = 1; i < m + 1; i++) {
    segs1.emplace_back(kek2[i - 1], kek2[i]);
  }
  if (segs1[0].first == segs1[0].second)
    segs.emplace_back(segs1[0]);
  else {
    segs.emplace_back(segs1[0].first, segs1[0].first);
    if (segs1[0].first + 1 <= segs1[0].second - 1)
      segs.emplace_back(segs1[0].first + 1, segs1[0].second - 1);
    segs.emplace_back(segs1[0].second, segs1[0].second);
  }
  for (int i = 1; i < m; i++) {
    if (segs1[i - 1].second == segs1[i].first) {
      if (segs1[i - 1].second + 1 <= segs1[i].second - 1) {
        segs.emplace_back(segs1[i - 1].second + 1, segs1[i].second - 1);
      }
      if (segs1[i - 1].second + 1 <= segs1[i].second)
        segs.emplace_back(segs1[i].second, segs1[i].second);
    } else {
      segs.emplace_back(segs1[i].first, segs1[i].first);
      if (segs1[i].first + 1 <= segs1[i].second - 1)
        segs.emplace_back(segs1[i].first + 1, segs1[i].second - 1);
      segs.emplace_back(segs1[i].second, segs1[i].second);
    }
  }
  m = segs.size();
  dp[0][0] = 1;
  for (int j = 1; j <= n; j++) {
    dp[j][0] = ismine(1, j, 0) * cnk(-segs[0].first + segs[0].second + 1, j);
  }
  for (int j = 0; j <= n; j++) {
    for (int i = 0; i < m - 1; i++) {
      dp[j][i + 1] += dp[j][i];
      dp[j][i + 1] %= mod;
      for (int k = 1; k + j <= n; k++) {
        long long mm = segs[i + 1].second + 1 - segs[i + 1].first;
        int nn = k;
        dp[j + k][i + 1] +=
            ismine(j + 1, j + k, i + 1) * cnk(mm, nn) * dp[j][i];
        dp[j + k][i + 1] %= mod;
      }
    }
  }
  long long zn = 1;
  for (int i = 0; i < n; i++) {
    zn *= ((y[i] - x[i] + 1) % mod);
    zn %= mod;
  }
  zn = inv(zn, mod);
  cout << (dp[n][m - 1] * zn) % mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  unsigned int beg_time = clock();
  int n = 1;
  for (int i = 0; i < n; i++) solve();
  unsigned int end_time = clock();
  return 0;
}
