#include <bits/stdc++.h>
using namespace std;
struct range {
  int l, r;
} arr[55];
int max_l[55][55], min_r[55][55];
int dp[55][55 * 4];
inline int Pow(int a, int n) {
  int ret = 1;
  int base = a;
  while (n) {
    if (n & 1)
      ret =
          ((((long long)ret * base) % 998244353ll + 998244353ll) % 998244353ll);
    base =
        ((((long long)base * base) % 998244353ll + 998244353ll) % 998244353ll);
    n >>= 1;
  }
  return ret;
}
inline int C(int n, int m) {
  int ret = 1;
  for (int i = n - m + 1; i <= n; i++)
    ret = ((((long long)ret * i) % 998244353ll + 998244353ll) % 998244353ll);
  for (int i = 1; i <= m; i++)
    ret = ((((long long)ret * Pow(i, 998244353ll - 2)) % 998244353ll +
            998244353ll) %
           998244353ll);
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i].l >> arr[i].r;
  for (int i = 1; i <= n; i++) {
    max_l[i][i] = arr[i].l;
    min_r[i][i] = arr[i].r;
    for (int j = i + 1; j <= n; j++) {
      max_l[i][j] = max(max_l[i][j - 1], arr[j].l);
      min_r[i][j] = min(min_r[i][j - 1], arr[j].r);
    }
  }
  set<int> s;
  for (int i = 1; i <= n; i++) {
    s.insert(arr[i].l);
    s.insert(arr[i].r);
  }
  vector<range> segs;
  int pre = -1;
  for (int pts : s) {
    if (pre != -1 && pre + 1 <= pts - 1)
      segs.emplace_back(range{pre + 1, pts - 1});
    segs.emplace_back(range{pts, pts});
    pre = pts;
  }
  int sz = (int)segs.size();
  reverse(segs.begin(), segs.end());
  fill(dp[0], dp[0] + sz + 1, 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= sz; j++) {
      for (int k = 1; k <= i; k++) {
        int r = min(min_r[i - k + 1][i], segs[j - 1].r),
            l = max(max_l[i - k + 1][i], segs[j - 1].l);
        if (l <= r)
          dp[i][j] =
              ((((long long)dp[i - k][j - 1] * C((r - l) + k, k) + dp[i][j]) %
                    998244353ll +
                998244353ll) %
               998244353ll);
      }
      dp[i][j] =
          ((((long long)dp[i][j] + dp[i][j - 1]) % 998244353ll + 998244353ll) %
           998244353ll);
    }
  int ans = dp[n][sz];
  for (int i = 1; i <= n; i++)
    ans = ((((long long)ans * Pow(arr[i].r - arr[i].l + 1, 998244353ll - 2)) %
                998244353ll +
            998244353ll) %
           998244353ll);
  cout << ans << endl;
  return 0;
}
