#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % 998244353;
    y = y / 2, x = (x * x) % 998244353;
  }
  return res % 998244353;
}
vector<vector<long long> > arr(101);
long long n;
long long l[51], r[51];
vector<long long> segment;
set<long long> lol;
long long dp[51][101];
long long calc[51][51][2];
long long comb(long long x, long long y, long long prev) {
  if (y == 0) return (x == 1 and prev == 1);
  if (x == 0) return 0;
  long long &ret = calc[x][y][prev];
  if (ret != -1) return ret;
  if (prev == 0) return ret = comb(x, y - 1, 1);
  ret = comb(x - 1, y, 0) + comb(x, y - 1, 1);
  ret %= 998244353;
  return ret;
}
long long func(long long i, long long j) {
  if (i == n) return 1;
  if (j >= segment.size() - 1) return 0;
  long long &ret = dp[i][j];
  if (ret != -1) return ret;
  vector<long long> poss;
  for (auto v : arr[j]) {
    if (v >= i) poss.emplace_back(v);
  }
  ret = func(i, j + 1);
  long long req = i;
  long long cnt = 1;
  long long pre = segment[j] - segment[j + 1];
  vector<long long> temp;
  temp.emplace_back(0);
  temp.emplace_back(pre);
  for (auto v : poss) {
    if (v != req) return ret;
    for (long long ii = 0; ii < (temp.size()); ++ii)
      ret = ret + func(req + 1, j + 1) % 998244353 *
                      (comb(min(segment[j] - segment[j + 1], ii), cnt, 0)) %
                      998244353 * temp[ii] % 998244353,
      ret %= 998244353;
    ret %= 998244353;
    req++;
    cnt++;
    if (cnt <= segment[j] - segment[j + 1])
      pre = pre * (segment[j] - segment[j + 1] - cnt + 1) % 998244353 *
            power(cnt, 998244353 - 2) % 998244353,
      temp.emplace_back(pre);
    pre %= 998244353;
  }
  return ret;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  long long deno = 1;
  for (long long i = 0; i < (n); ++i)
    cin >> l[i] >> r[i], lol.insert(l[i]), lol.insert(r[i] + 1),
        deno = deno * (r[i] - l[i] + 1) % 998244353;
  for (auto v : lol) segment.emplace_back(v);
  reverse(segment.begin(), segment.end());
  for (long long i = 0; i < (segment.size() - 1); ++i) {
    long long y = segment[i] - 1;
    long long x = segment[i + 1];
    for (long long j = 0; j < (n); ++j) {
      if (l[j] <= x and r[j] >= y) arr[i].emplace_back(j);
    }
  }
  memset(dp, -1, sizeof(dp));
  memset(calc, -1, sizeof(calc));
  cout << (func(0, 0) * power(deno, 998244353 - 2)) % 998244353;
}
