#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }
inline int mul(int x, int y) { return 1LL * x * y % mod; }
inline int power(int x, int y) {
  int res = 1;
  for (; y; y >>= 1, x = mul(x, x))
    if (y & 1) res = mul(res, x);
  return res;
}
int C(int n, int m) {
  int res = 1, tp = 1;
  for (int i = n - m + 1; i <= n; i++) res = mul(res, i);
  for (int i = 1; i <= m; i++) tp = mul(tp, i);
  return mul(res, power(tp, mod - 2));
}
const int N = 55, P = 105;
int l[N], r[N], p[P], len[P];
int f[N][P];
int main() {
  int n, pc = 0, all = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", l + i, r + i), ++r[i];
    p[++pc] = l[i];
    p[++pc] = r[i];
    all = mul(all, r[i] - l[i]);
  }
  sort(p + 1, p + 1 + pc);
  pc = unique(p + 1, p + 1 + pc) - p - 1;
  for (int i = 1; i <= n; i++) {
    l[i] = lower_bound(p + 1, p + 1 + pc, l[i]) - p;
    r[i] = lower_bound(p + 1, p + 1 + pc, r[i]) - p;
  }
  for (int i = 1; i < pc; i++) len[i] = p[i + 1] - p[i];
  for (int i = 1; i <= pc; i++) f[0][i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = pc - 1; j >= 1; j--) {
      if (j >= l[i] && j + 1 <= r[i])
        for (int k = i - 1; k >= 0; k--) {
          f[i][j] =
              add(f[i][j], mul(f[k][j + 1], C(len[j] + i - k - 1, i - k)));
          if (!(j >= l[k] && j + 1 <= r[k])) break;
        }
      f[i][j] = add(f[i][j], f[i][j + 1]);
    }
  }
  printf("%d\n", mul(f[n][1], power(all, mod - 2)));
  return 0;
}
