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 comment(linker, "/STACK:16777216")
using namespace std;
inline long FastMax(long x, long y) {
  return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y;
}
inline long FastMin(long x, long y) {
  return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x;
}
long IR[] = {0, -1, 0, 1, -1, -1, 1, 1};
long IC[] = {1, 0, -1, 0, 1, -1, -1, 1};
long n;
long L[77 + 7];
long R[77 + 7];
bool vi[7][7][10007][2];
double pr[7][7][10007][2];
inline long max(long a, long b) { return a > b ? a : b; }
double Find(long i, long w, long a, bool u) {
  if (i > n) return u == true;
  if (vi[i][w][a][u]) return pr[i][w][a][u];
  vi[i][w][a][u] = true;
  if (i == w) return pr[i][w][a][u] = Find(i + 1, w, a, u);
  pr[i][w][a][u] = 0;
  if (L[i] <= a and R[i] >= a)
    pr[i][w][a][u] += (1.0 / (R[i] - L[i] + 1)) * Find(i + 1, w, a, true);
  long max_i = min(a - 1, R[i]);
  if (L[i] <= max_i)
    pr[i][w][a][u] +=
        ((max_i - L[i] + 1.0) / (R[i] - L[i] + 1)) * Find(i + 1, w, a, u);
  return pr[i][w][a][u];
}
double tryAll(long i, long a, long u) {
  if (i > n) return u >= 2;
  double p = 0;
  if (L[i] <= a and R[i] >= a)
    p += (1.0 / (R[i] - L[i] + 1)) * tryAll(i + 1, a, u + 1);
  long max_i = min(a - 1, R[i]);
  if (L[i] <= max_i)
    p += ((max_i - L[i] + 1.0) / (R[i] - L[i] + 1)) * tryAll(i + 1, a, u);
  return p;
}
int main(void) {
  long long i, j, a, w, Icase;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> L[i] >> R[i];
  }
  double ans = 0;
  for (a = 1; a <= 10000; a++) {
    double p;
    for (w = 1; w <= n; w++) {
      long min_w = max(a + 1, L[w]);
      if (min_w > R[w]) continue;
      double p = Find(1, w, a, false);
      p *= (R[w] - min_w + 1.0) / (R[w] - L[w] + 1.0);
      ans += p * a;
    }
    ans += tryAll(1, a, 0) * a;
  }
  printf("%.10lf\n", ans);
  return 0;
}