#include <bits/stdc++.h>
inline int fp(int x, int k) {
  int res = 1;
  for (; k; k >>= 1, x = 1ll * x * x % 998244353)
    if (k & 1) res = 1ll * res * x % 998244353;
  return res;
}
int n, l[55], r[55];
int val[55 << 1], tot, len[55 << 1];
namespace L {
int f[55][55], g[55][55], w[55][55];
inline void init() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= i + 1; j++) {
      for (int k = 0; k <= i; k++)
        for (int x = 1; x <= j; x++) f[k][x] = 0;
      f[0][j] = 1;
      for (int k = 1; k <= i; k++)
        for (int x = 1; x <= j; x++)
          for (int y = x; y <= j; y++)
            f[k][x] = (f[k][x] + f[k - 1][y]) % 998244353;
      for (int x = 1; x <= j; x++) g[i][j] = (g[i][j] + f[i][x]) % 998244353;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= i + 1; j++) {
      w[i][j] = g[i][j];
      for (int k = 1; k <= i + 1; k++)
        if (k != j)
          w[i][j] = 1ll * w[i][j] *
                    fp((j - k + 998244353) % 998244353, 998244353 - 2) %
                    998244353;
    }
}
inline int cal(int x, int y) {
  if (x <= y + 1) return g[y][x];
  int tmp = 1;
  for (int i = 1; i <= y + 1; i++)
    tmp = 1ll * tmp * (x - i + 998244353) % 998244353;
  int res = 0;
  for (int i = 1; i <= y + 1; i++)
    res = (res + 1ll * tmp * w[y][i] % 998244353 * fp(x - i, 998244353 - 2) %
                     998244353) %
          998244353;
  return res;
}
}  // namespace L
int f[55][55 << 1];
int ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l[i], &r[i]);
    r[i]++;
    val[++tot] = l[i];
    val[++tot] = r[i];
  }
  std::sort(val + 1, val + tot + 1);
  tot = std::unique(val + 1, val + tot + 1) - val - 1;
  for (int i = 1; i <= n; i++) {
    l[i] = std::lower_bound(val + 1, val + tot + 1, l[i]) - val;
    r[i] = std::lower_bound(val + 1, val + tot + 1, r[i]) - val;
  }
  for (int i = 1; i < tot; i++) len[i] = val[i + 1] - val[i];
  L::init();
  f[0][tot] = 1;
  r[0] = tot + 1;
  for (int i = 1; i <= n; i++)
    for (int x = l[i]; x < r[i]; x++)
      for (int j = i; j && l[j] <= x && x < r[j]; j--)
        for (int y = x + 1; y < r[j - 1]; y++)
          f[i][x] = (f[i][x] + 1ll * L::cal(len[x], i - j + 1) * f[j - 1][y] %
                                   998244353) %
                    998244353;
  for (int i = 1; i <= tot; i++) ans = (ans + f[n][i]) % 998244353;
  for (int i = 1; i <= n; i++)
    ans = 1ll * ans * fp(val[r[i]] - val[l[i]], 998244353 - 2) % 998244353;
  printf("%d\n", ans);
}
