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;
const int int_inf = 0x3f3f3f3f;
const long long ll_inf = 0x3f3f3f3f3f3f3f3fll;
const double pi = acos(-1.0);
const double eps = 1e-8;
template <class T>
inline T abs(const T first) {
  return first < 0 ? -first : first;
}
template <class T>
inline void get_min(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void get_max(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void fix(T &a, T mo) {
  while (a >= mo) a -= mo;
  while (a < 0) a += mo;
}
template <class T>
inline void inc(T &a, T b, T mo) {
  a += b;
  fix(a, mo);
}
template <class T>
inline void dec(T &a, T b, T mo) {
  a -= b;
  fix(a, mo);
}
template <class T>
inline T mul_mod(T a, T b, T mo) {
  T ans = 0;
  for (; b; b >>= 1) {
    if (b & 1) inc(ans, a, mo);
    inc(a, a, mo);
  }
  return ans;
}
template <class T>
inline T pow_mod(T a, T b, T mo) {
  T ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans = (long long)ans * a % mo;
    a = (long long)a * a % mo;
  }
  return ans;
}
template <class T>
inline T big_pow_mod(T a, T b, T mo) {
  T ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans = mul_mod(ans, a, mo);
    a = mul_mod(a, a, mo);
  }
  return ans;
}
template <class T>
inline T pow(T a, int b) {
  T ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans *= a;
    a *= a;
  }
  return ans;
}
template <class T>
inline T sqr(T first) {
  return first * first;
}
template <class T>
inline int sgn(T first) {
  if (first > eps) return 1;
  if (first < -eps) return -1;
  return 0;
}
template <class T>
inline void read_int(T &first) {
  first = 0;
  char ch;
  bool flag = 0;
  while (ch = getchar(), !isdigit(ch) && ch != '-')
    ;
  if (ch == '-')
    flag = 1;
  else
    first = ch - '0';
  while (ch = getchar(), isdigit(ch))
    first = (first << 3) + first + first + ch - '0';
  if (flag) first = -first;
}
template <class T>
inline void read_float(T &first) {
  first = 0;
  long double now_pos = 0.1;
  char ch;
  while (ch = getchar(), !isdigit(ch) && ch != '-')
    ;
  bool flag = 0, decimal = 0;
  if (ch == '-')
    flag = 1;
  else if (ch == '.')
    decimal = 1;
  while (ch = getchar(), isdigit(ch) || ch == '.') {
    if (ch == '.')
      decimal = 1;
    else if (decimal) {
      first += now_pos * (ch - '0');
      now_pos *= 0.1;
    } else
      first = first * 10 + ch - '0';
  }
  if (flag) first = -first;
}
int l[100], r[100];
int _max[100], _sec[100], _other[100];
int main() {
  int n;
  read_int(n);
  long double base = 1;
  for (int i = 0; i < n; i++) {
    read_int(l[i]);
    read_int(r[i]);
    base *= r[i] - l[i] + 1;
  }
  long double ans = 0;
  for (int first = 0; first < (1 << n); first++)
    for (int second = 0; second < (1 << n); second++) {
      if (first & second) continue;
      int n1 = 0, n2 = 0, n3 = 0;
      for (int i = 0; i < n; i++)
        if (first & (1 << i))
          _max[n1++] = i;
        else if (second & (1 << i))
          _sec[n2++] = i;
        else
          _other[n3++] = i;
      if (n1 == 0) continue;
      if (n1 == 1) {
        if (n2 == 0) continue;
        int up = int_inf, down = 0;
        for (int i = 0; i < n2; i++) {
          int first = _sec[i];
          get_min(up, r[first]);
          get_max(down, l[first]);
        }
        int L = l[_max[0]], R = r[_max[0]];
        for (int sec = down; sec <= up; sec++) {
          if (R <= sec) continue;
          long double now_ans = R - max(L, sec + 1) + 1;
          for (int i = 0; i < n3; i++) {
            int first = _other[i];
            if (l[first] >= sec)
              now_ans = 0;
            else
              now_ans *= min(r[first], sec - 1) - l[first] + 1;
          }
          ans += now_ans * sec;
        }
      } else {
        if (n2 != 0) continue;
        int up = int_inf, down = 0;
        for (int i = 0; i < n1; i++) {
          int first = _max[i];
          get_min(up, r[first]);
          get_max(down, l[first]);
        }
        for (int sec = down; sec <= up; sec++) {
          long double now_ans = 1;
          for (int i = 0; i < n3; i++) {
            int first = _other[i];
            if (l[first] >= sec)
              now_ans = 0;
            else
              now_ans *= min(r[first], sec - 1) - l[first] + 1;
          }
          ans += now_ans * sec;
        }
      }
    }
  ans /= base;
  printf("%.10f\n", (double)ans);
  return 0;
}