Problem: Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receives a request with details about the user, web page and ad slot and they have to respond within those 100 milliseconds with a bid they would pay for putting an advertisement on that ad slot. The company that suggests the highest bid wins the auction and gets to place its advertisement. If there are several companies tied for the highest bid, the winner gets picked at random.

However, the company that won the auction does not have to pay the exact amount of its bid. In most of the cases, a second-price auction is used. This means that the amount paid by the company is equal to the maximum of all the other bids placed for this ad slot.

Let's consider one such bidding. There are n companies competing for placing an ad. The i-th of these companies will bid an integer number of microdollars equiprobably randomly chosen from the range between Li and Ri, inclusive. In the other words, the value of the i-th company bid can be any integer from the range [Li, Ri] with the same probability. 

Determine the expected value that the winner will have to pay in a second-price auction.

Input

The first line of input contains an integer number n (2 ≤ n ≤ 5). n lines follow, the i-th of them containing two numbers Li and Ri (1 ≤ Li ≤ Ri ≤ 10000) describing the i-th company's bid preferences.

This problem doesn't have subproblems. You will get 8 points for the correct submission.

Output

Output the answer with absolute or relative error no more than 1e - 9.

Examples

Input

3
4 7
8 10
5 5


Output

5.7500000000


Input

3
2 5
3 4
1 6


Output

3.5000000000

Note

Consider the first example. The first company bids a random integer number of microdollars in range [4, 7]; the second company bids between 8 and 10, and the third company bids 5 microdollars. The second company will win regardless of the exact value it bids, however the price it will pay depends on the value of first company's bid. With probability 0.5 the first company will bid at most 5 microdollars, and the second-highest price of the whole auction will be 5. With probability 0.25 it will bid 6 microdollars, and with probability 0.25 it will bid 7 microdollars. Thus, the expected value the second company will have to pay is 0.5·5 + 0.25·6 + 0.25·7 = 5.75.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int inf_int = 2e9;
long long inf_ll = 2e18;
const double pi = 3.1415926535898;
template <typename T, typename T1>
void prin(vector<pair<T, T1> >& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i].first << " " << a[i].second << "\n";
  }
}
template <typename T>
void prin(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i];
    if (i < a.size() - 1)
      cout << " ";
    else
      cout << "\n";
  }
}
template <typename T>
void prin(set<T>& a) {
  for (auto it = a.begin(); it != a.end(); it++) {
    cout << *it << " ";
  }
}
template <typename T>
void prin_new_line(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << "\n";
  }
}
template <typename T, typename T1>
void prin_new_line(vector<pair<T, T1> >& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i].first << " " << a[i].second << "\n";
  }
}
int sum_vec(vector<int>& a) {
  int s = 0;
  for (int i = 0; i < a.size(); i++) {
    s += a[i];
  }
  return s;
}
template <typename T>
T max(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = max(ans, a[i]);
  }
  return ans;
}
template <typename T>
T min(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = min(ans, a[i]);
  }
  return ans;
}
template <typename T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <typename T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
long double s_triangle(long double x1, long double y1, long double x2,
                       long double y2, long double x3, long double y3) {
  return abs(((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) / 2);
}
bool overflow(long long a, long long b) {
  if (a * b / b != a) return true;
  return false;
}
bool debug = 0;
const int maxn = 1e5 + 100;
long long mod = 1e9 + 7;
double a[5][maxn];
double pref[5][maxn];
void solve() {
  int n;
  cin >> n;
  int l[n], r[n];
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    mx = max(mx, r[i]);
    double x = 1.0 / (r[i] - l[i] + 1);
    for (int e = l[i]; e <= r[i]; e++) {
      a[i][e] = x;
    }
  }
  mx = mx + 2;
  for (int i = 0; i < n; i++) {
    for (int e = 1; e <= mx; e++) {
      pref[i][e] = pref[i][e - 1] + a[i][e];
    }
  }
  double ans = 0;
  for (int e = mx - 2; e >= 1; e--) {
    double ans1 = 0;
    for (int i = 0; i < n; i++) {
      if (r[i] > e) {
        double x = pref[i][mx] - pref[i][e];
        int mask = 0;
        for (int j = 0; j < n; j++) {
          if (i == j) {
            continue;
          }
          if (l[j] <= e && r[j] >= e) {
            mask = mask + (1 << j);
          }
        }
        int s = mask;
        while (s) {
          double y = 1;
          for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if ((s >> j) & 1) {
              y = y * a[j][e];
            } else {
              y = y * pref[j][e - 1];
            }
          }
          s = (s - 1) & mask;
          ans1 += x * y;
        }
      }
    }
    int mask = 0;
    for (int j = 0; j < n; j++) {
      if (l[j] <= e && r[j] >= e) {
        mask = mask + (1 << j);
      }
    }
    int s = mask;
    while (s) {
      if (s & (s - 1)) {
        double y = 1;
        for (int j = 0; j < n; j++) {
          if ((s >> j) & 1) {
            y = y * a[j][e];
          } else {
            y = y * pref[j][e - 1];
          }
        }
        ans1 += y;
      }
      s = (s - 1) & mask;
    }
    ans += ans1 * e;
  }
  cout << fixed << setprecision(18) << ans;
}
int main() {
  if (!debug) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  int t = 1;
  while (t--) solve();
  return 0;
}