#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N_MAX = 50;
int pwr(int a, int b) {
  if (b == 0) return 1;
  if (b & 1) return 1LL * pwr(a, (b ^ 1)) * a % MOD;
  int aux = pwr(a, (b >> 1));
  return 1LL * aux * aux % MOD;
}
int n;
int invf[N_MAX + 2];
struct Task {
  int l, r;
};
Task tasks[N_MAX + 2];
int points[N_MAX * 2 + 2];
struct Segment {
  int l, r;
};
Segment segments[N_MAX * 4 + 2];
int cntSeg;
int combrep[N_MAX * 4 + 2][N_MAX + 2];
int lmax[N_MAX + 2][N_MAX + 2];
int rmin[N_MAX + 2][N_MAX + 2];
int invplg[N_MAX + 2][N_MAX + 2];
int dp[N_MAX + 2][N_MAX * 4 + 2][N_MAX + 2];
int sdp[N_MAX + 2][N_MAX * 4 + 2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = n; i >= 1; i--) {
    cin >> tasks[i].l >> tasks[i].r;
    points[i * 2 - 1] = tasks[i].l;
    points[i * 2] = tasks[i].r;
  }
  sort(points + 1, points + n * 2 + 1);
  segments[++cntSeg] = Segment{points[1], points[1]};
  for (int i = 2; i <= n * 2; i++)
    if (points[i] > points[i - 1]) {
      if (points[i - 1] + 1 <= points[i] - 1)
        segments[++cntSeg] = Segment{points[i - 1] + 1, points[i] - 1};
      segments[++cntSeg] = Segment{points[i], points[i]};
    }
  invf[0] = 1;
  for (int i = 1; i <= n; i++)
    invf[i] = 1LL * invf[i - 1] * pwr(i, MOD - 2) % MOD;
  for (int i = 1; i <= cntSeg; i++)
    for (int j = 1; j <= n; j++) {
      combrep[i][j] = 1;
      int lg = segments[i].r - segments[i].l + 1;
      for (int k = lg; k <= lg + j - 1; k++)
        combrep[i][j] = 1LL * combrep[i][j] * k % MOD;
      combrep[i][j] = 1LL * combrep[i][j] * invf[j] % MOD;
    }
  for (int i = 1; i <= n; i++) {
    lmax[i][i - 1] = INT_MIN;
    rmin[i][i - 1] = INT_MAX;
    invplg[i][i - 1] = 1;
    for (int j = i; j <= n; j++) {
      lmax[i][j] = max(lmax[i][j - 1], tasks[j].l);
      rmin[i][j] = min(rmin[i][j - 1], tasks[j].r);
      invplg[i][j] = 1LL * invplg[i][j - 1] *
                     pwr(tasks[j].r - tasks[j].l + 1, MOD - 2) % MOD;
    }
  }
  dp[0][0][0] = 1;
  sdp[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= cntSeg; j++)
      for (int k = 1; k <= i; k++) {
        if (lmax[i - k + 1][i] > segments[j].l ||
            segments[j].r > rmin[i - k + 1][i])
          break;
        for (int j1 = 0; j1 < j; j1++) {
          dp[i][j][k] += sdp[i - k][j1];
          if (dp[i][j][k] >= MOD) dp[i][j][k] -= MOD;
        }
        dp[i][j][k] = 1LL * dp[i][j][k] * combrep[j][k] % MOD;
        dp[i][j][k] = 1LL * dp[i][j][k] * invplg[i - k + 1][i] % MOD;
        sdp[i][j] += dp[i][j][k];
        if (sdp[i][j] >= MOD) sdp[i][j] -= MOD;
      }
  int ans = 0;
  for (int j = 1; j <= cntSeg; j++) {
    ans += sdp[n][j];
    if (ans >= MOD) ans -= MOD;
  }
  cout << ans << "\n";
  return 0;
}
