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>
#pragma warning(disable : 4996)
using namespace std;
int pri[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
long long fun(long long a, long long b, long long c) {
  a %= c;
  b %= c;
  long long s = 0;
  while (b) {
    if (b & 1) {
      s = s + a;
      if (s >= c) s = s - c;
    }
    a = a << 1;
    if (a >= c) a = a - c;
    b = b >> 1;
  }
  return s;
}
long long pow1(long long x, long long n, long long m) {
  if (n == 0) return 1;
  if (n == 1) return x % m;
  if (n % 2 == 0)
    return pow1(fun(x, x, m), n / 2, m) % m;
  else
    return fun(pow1(fun(x, x, m), n / 2, m), x, m);
}
bool Miller_Rabin(long long n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (!(n & 1)) return false;
  long long k = 0, i, j, m = n - 1, a;
  while (!(m & 1)) m >>= 1, k++;
  for (i = 0; i < 10; i++) {
    if (pri[i] >= n) return true;
    a = pow1(pri[i], m, n);
    if (a == 1) continue;
    for (j = 0; j < k; j++) {
      if (a == n - 1) break;
      a = fun(a, a, n);
    }
    if (j == k) return false;
  }
  return true;
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  if (a % 2 == 0 && b % 2 == 0) return gcd(a >> 1, b >> 1) << 1;
  if (a % 2 == 0) return gcd(a >> 1, b);
  if (b % 2 == 0) return gcd(a, b >> 1);
  return gcd((a + b) >> 1, (a - b) >> 1);
}
long long pollard_rho(long long c, long long n) {
  long long i, x, y, k, d;
  i = 1;
  x = y = rand() % n;
  k = 2;
  do {
    i++;
    d = gcd(n + y - x, n);
    if (d > 1 && d < n) return d;
    if (i == k) y = x, k <<= 1;
    x = (fun(x, x, n) + n - c) % n;
  } while (y != x);
  return n;
}
long long rho(long long n) {
  if (Miller_Rabin(n)) return n;
  long long t = n;
  while (t >= n) t = pollard_rho(rand() % (n - 1) + 1, n);
  long long a = rho(t);
  long long b = rho(n / t);
  return a < b ? a : b;
}
int n;
int s[10], t[10];
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d%d", &s[i], &t[i]);
    double ans = 0;
    for (int i = 0; i < n; i++) {
      bool leap = true;
      for (int j = 0; j < n; j++)
        if (i != j && t[i] < s[j]) {
          leap = false;
          break;
        }
      if (!leap) continue;
      for (int k = 0; k < n; k++) {
        if (k == i) continue;
        leap = true;
        for (int j = 0; j < n; j++)
          if (j != i && j != k && t[k] < s[j]) {
            leap = false;
            break;
          }
        if (!leap) continue;
        for (int l = s[k]; l <= t[k]; l++) {
          double tmp = 1.0;
          for (int a = 0; a < n; a++) {
            if (a != i && a != k) {
              if (l >= s[a]) {
                if (l <= t[a]) {
                  if (a > k)
                    tmp *= (double)(l - s[a] + 1) / (t[a] - s[a] + 1);
                  else
                    tmp *= (double)(l - s[a]) / (t[a] - s[a] + 1);
                } else
                  ;
              } else
                tmp = 0;
            }
          }
          double bi = 0;
          if (l < s[i])
            bi = 1.0;
          else if (l > t[i])
            bi = 0.0;
          else {
            if (i < k)
              bi = (double)(t[i] - l + 1) / (t[i] - s[i] + 1);
            else
              bi = (double)(t[i] - l) / (t[i] - s[i] + 1);
          }
          ans += (double)l / (t[k] - s[k] + 1) * bi * tmp;
        }
      }
    }
    printf("%.15lf\n", ans);
  }
  return 0;
}