#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "URDL";
const long long MOD2 = (long long)998244353 * (long long)998244353;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 998244353) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
int dp[52][135], l[55], r[55], L[135], R[135], cnt;
int inv[135];
void fmain(int tid) {
  scanf("%d", &n);
  inv[0] = 1;
  for (int(i) = 1; (i) <= (int)(60); (i)++) inv[i] = fastPow(i, 998244353 - 2);
  vector<int> vp;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d%d", l + i, r + i);
    r[i]++;
    vp.push_back(l[i]);
    vp.push_back(r[i]);
  }
  sort(vp.begin(), vp.end());
  int N = unique(vp.begin(), vp.end()) - vp.begin();
  for (int(i) = 0; (i) < (int)(N - 1); (i)++) {
    cnt++;
    L[cnt] = vp[i];
    R[cnt] = vp[i + 1];
  }
  for (int(i) = 1; (i) <= (int)(cnt); (i)++) dp[0][i] = 1;
  dp[0][cnt + 1] = 1;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    for (int(x) = 1; (x) <= (int)(cnt); (x)++)
      if (l[i] <= L[x] && R[x] <= r[i]) {
        int sz = R[x] - L[x], bs = 1;
        int com = sz;
        for (int j = i - 1; j >= 0; j--) {
          if (l[j + 1] <= L[x] && R[x] <= r[j + 1]) {
            addmod(dp[i][x], (long long)dp[j][x + 1] * com % 998244353);
            sz++;
            bs++;
            com = (long long)com * sz % 998244353 * inv[bs] % 998244353;
          } else
            break;
        }
      }
    for (int x = cnt - 1; x > 0; x--) addmod(dp[i][x], dp[i][x + 1]);
  }
  int ans = dp[n][1];
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    int sz = r[i] - l[i];
    ans = (long long)ans * fastPow(sz, 998244353 - 2) % 998244353;
  }
  printf("%d\n", ans);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
