#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int n;
int A[53], B[53];
int fac[53];
vector<pair<int, int> > ren;
vector<vector<int> > vecs;
int pwr(int a, int b) {
  if (b == 0)
    return 1;
  else if (b == 2)
    return (1LL * a * a) % MOD;
  else if (b & 1)
    return (1LL * pwr(a, b - 1) * a) % MOD;
  else
    return pwr(pwr(a, b / 2), 2);
}
int C(int n, int k) {
  int res = 1;
  for (int i = 0; i < k; i++) res = (1LL * res * (n - i)) % MOD;
  return (1LL * res * pwr(fac[k], MOD - 2)) % MOD;
}
int get_sum(vector<int> vec, int x) {
  int sum = 0;
  for (int i = 0; i < vec.size(); i++) {
    sum += (1LL * vec[i] * C(x, i + 1)) % MOD;
    sum %= MOD;
  }
  return sum;
}
vector<int> get_vec(vector<int> vec, int delA, int dif) {
  vector<int> ans = {((delA + get_sum(vec, dif)) % MOD)};
  for (int i = 0; i < vec.size(); i++) {
    vector<int> tmp;
    for (int j = i + 1; j < vec.size(); j++) tmp.push_back(vec[j]);
    ans.push_back((vec[i] + get_sum(tmp, dif)) % MOD);
  }
  return ans;
}
void update(int x, int y) {
  vector<pair<int, int> > nren;
  vector<vector<int> > nvecs;
  bool bol1 = 0, bol2 = 0;
  for (pair<int, int> i : ren) {
    if (x <= i.first && i.second <= y)
      nren.push_back(i);
    else if (i.first <= x && x <= i.second && i.second <= y) {
      bol1 = 1;
      nren.push_back({x, i.second});
    } else if (x <= i.first && i.first <= y && y <= i.second) {
      bol2 = 1;
      nren.push_back({i.first, y});
    }
  }
  if (nren.size() == 0)
    nren.push_back({x, y});
  else {
    if (bol2 == 0 && nren.back().second != y)
      nren.push_back({nren.back().second + 1, y});
  }
  sort(nren.begin(), nren.end());
  for (int i = 0; i < nren.size(); i++) {
    int delA = 0;
    bool bol = 0;
    for (int j = 0; j < ren.size(); j++) {
      if (ren[j].second < nren[i].first) {
        delA =
            (delA + get_sum(vecs[j], ren[j].second - ren[j].first + 1)) % MOD;
      } else if (ren[i].first <= nren[i].first) {
        bol = 1;
        nvecs.push_back(
            get_vec(vecs[j], delA, nren[i].first - ren[j].first + 1));
        delA = (delA + get_sum(vecs[j], vecs[j].size())) % MOD;
        break;
      }
    }
    if (!bol) nvecs.push_back({delA});
  }
  ren = nren;
  vecs = nvecs;
}
int main() {
  fac[0] = 1;
  for (int i = 1; i <= 50; i++) fac[i] = (1LL * i * fac[i - 1]) % MOD;
  int com = 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &A[i], &B[i]);
    com = (1LL * com * (B[i] - A[i] + 1)) % MOD;
  }
  ren.push_back({-1, -1});
  vecs.push_back({{1}});
  for (int i = 0; i < n; i++) update(A[n - i - 1], B[n - i - 1]);
  int res = 0;
  for (int i = 0; i < ren.size(); i++) {
    res += get_sum(vecs[i], ren[i].second - ren[i].first + 1);
    res %= MOD;
  }
  printf("%d\n", (1LL * res * pwr(com, MOD - 2)) % MOD);
}
