#include <bits/stdc++.h>
using namespace std;
const int N = 50, mod = 998244353;
int add(int a, int b, int p = mod) { return a + b >= p ? a + b - p : a + b; }
int sub(int a, int b, int p = mod) { return a - b < 0 ? a - b + p : a - b; }
int mul(int a, int b, int p = mod) { return (long long)a * b % p; }
void sadd(int &a, int b, int p = mod) { a = add(a, b, p); }
void ssub(int &a, int b, int p = mod) { a = sub(a, b, p); }
void smul(int &a, int b, int p = mod) { a = mul(a, b, p); }
int Power(int a, int k, int p = mod) {
  int res = 1;
  for (; k; k >>= 1, smul(a, a, p))
    if (k & 1) smul(res, a, p);
  return res;
}
int Get_inv(int a, int p = mod) { return Power(a, p - 2, p); }
int n, l[N + 9], r[N + 9];
int ord[N * 2 + 9], co;
void into() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &l[i], &r[i]);
    ord[++co] = --l[i];
    ord[++co] = r[i];
  }
}
void Get_lr() {
  sort(ord + 1, ord + co + 1);
  co = unique(ord + 1, ord + co + 1) - ord - 1;
  for (int i = 1; i <= n; ++i) {
    l[i] = lower_bound(ord + 1, ord + co + 1, l[i]) - ord;
    r[i] = lower_bound(ord + 1, ord + co + 1, r[i]) - ord;
  }
}
int inv[N + 9];
void Get_inv() {
  inv[1] = 1;
  for (int i = 2; i <= n; ++i) inv[i] = mul(mod - mod / i, inv[mod % i]);
}
int c[N * 2 + 9][N + 9];
void Get_c() {
  for (int i = 2; i <= co; ++i) {
    int t = ord[i] - ord[i - 1] - 1;
    c[i][0] = 1;
    for (int j = 1; j <= n; ++j)
      c[i][j] = t ? mul(c[i][j - 1], mul(t + j, inv[j])) : 1;
  }
}
int dp[N + 9][N + 9][N * 2 + 9], ans;
void Get_dp() {
  for (int i = l[1] + 1; i <= r[1]; ++i) dp[1][1][i] = 1;
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j < i; ++j)
      for (int k = l[i] + 1; k <= r[i]; ++k) dp[i][j][k] = dp[i - 1][j][k];
    for (int j = l[i] + 1; j <= r[i]; ++j)
      for (int k = 1; k < i; ++k)
        for (int t = j + 1; t <= co; ++t)
          sadd(dp[i][i][j], mul(dp[i - 1][k][t], c[t][i - k]));
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 2; j <= co; ++j) sadd(ans, mul(dp[n][i][j], c[j][n - i + 1]));
  for (int i = 1; i <= n; ++i) smul(ans, Get_inv(ord[r[i]] - ord[l[i]]));
}
void work() {
  Get_lr();
  Get_inv();
  Get_c();
  Get_dp();
}
void outo() { printf("%d\n", ans); }
int main() {
  into();
  work();
  outo();
  return 0;
}
