#include <bits/stdc++.h>
using namespace std;
const int maxn = 55, mod = 998244353;
int n, l[maxn], r[maxn], pp[maxn * 2], cnt;
long long f[maxn][maxn * 2], s[maxn][maxn * 2];
long long Power(long long x, long long p) {
  long long res = 1;
  for (; p; p >>= 1, x = x * x % mod)
    if (p & 1) res = res * x % mod;
  return res;
}
long long calc(int i, int y) {
  int x = pp[i + 1] - pp[i] + y - 1;
  long long res = x;
  for (int i(1), i_END(y - 1); i <= i_END; i++)
    x--, res = res * x % mod * Power(i + 1, mod - 2) % mod;
  return res;
}
int main() {
  scanf("%d", &n);
  long long PI = 1;
  for (int i(1), i_END(n); i <= i_END; i++)
    scanf("%d%d", &l[i], &r[i]), r[i]++, pp[++cnt] = l[i], pp[++cnt] = r[i];
  sort(pp + 1, pp + 1 + cnt);
  cnt = unique(pp + 1, pp + 1 + cnt) - pp - 1;
  for (int i(1), i_END(n); i <= i_END; i++) {
    PI = PI * (r[i] - l[i]) % mod;
    l[i] = lower_bound(pp + 1, pp + 1 + cnt, l[i]) - pp;
    r[i] = lower_bound(pp + 1, pp + 1 + cnt, r[i]) - pp;
  }
  f[0][cnt] = 1;
  for (int i(0), i_END(cnt); i <= i_END; i++) s[0][i] = 1;
  for (int i(1), i_END(n); i <= i_END; i++) {
    for (int j(l[i]), j_END(r[i] - 1); j <= j_END; j++) {
      for (int k = i; k >= 1 && l[k] <= j && j < r[k]; k--) {
        f[i][j] = (f[i][j] + s[k - 1][j + 1] * calc(j, i - k + 1) % mod) % mod;
      }
    }
    for (int j(cnt), j_END(1); j >= j_END; j--)
      s[i][j] = (s[i][j + 1] + f[i][j]) % mod;
  }
  printf("%lld\n", s[n][1] * Power(PI, mod - 2) % mod);
  return 0;
}
