#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;
const ll N = 100 + 5, mod = 998244353;
ll n, l[N], r[N];
ll dp[N][N][N];
vector<ll> vec;
ll C[N][N];
inline ll pw(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = 1ll * res * a % mod;
    a = 1ll * a * a % mod;
    b >>= 1;
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    r[i]++;
    vec.push_back(l[i]);
    vec.push_back(r[i]);
  }
  ll tmp = 0;
  for (ll i = l[1]; i < r[1]; i++) tmp += max(0ll, r[0] - max(l[0], i));
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  for (ll i = 0; i < n; i++) {
    l[i] = lower_bound(vec.begin(), vec.end(), l[i]) - vec.begin();
    r[i] = lower_bound(vec.begin(), vec.end(), r[i]) - vec.begin();
  }
  for (ll i = 0; i < (ll)vec.size() - 1; i++) {
    ll val = vec[i + 1] - vec[i];
    C[i][0] = 1;
    for (ll j = 1; j < N; j++)
      C[i][j] = 1ll * C[i][j - 1] * (val - 1 + j) % mod * pw(j, mod - 2) % mod;
  }
  for (ll i = l[0]; i < r[0]; i++) dp[0][i][1] = 1;
  ll sum;
  for (ll i = 1; i < n; i++) {
    sum = 0;
    for (ll j = (ll)vec.size() - 2; j >= l[i]; j--) {
      if (j < r[i]) dp[i][j][1] = sum;
      for (ll k = 1; k <= i; k++) {
        if (j < r[i]) dp[i][j][k + 1] = dp[i - 1][j][k];
        sum = (sum + 1ll * dp[i - 1][j][k] * C[j][k]) % mod;
      }
    }
  }
  ll ans = 0;
  for (ll j = l[n - 1]; j < r[n - 1]; j++)
    for (ll k = 1; k <= n; k++)
      ans = (ans + 1ll * dp[n - 1][j][k] * C[j][k]) % mod;
  ll res = 1;
  for (ll i = 0; i < n; i++) res = 1ll * res * (vec[r[i]] - vec[l[i]]) % mod;
  cout << 1ll * ans * pw(res, mod - 2) % mod << '\n';
}
