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;
#pragma comment(linker, "/STACK:64000000")
const int infi = 1e9 + 7;
const long long infl = 1e18;
inline int readChar();
inline void writeChar(int x);
inline void writeWord(const char *s);
inline void flush();
static const int buf_size = 4096;
inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin);
  if (pos == len) return -1;
  return buf[pos++];
}
inline int readChar() {
  int c = getChar();
  while (c >= 0 && c <= 32) c = getChar();
  return c;
}
inline int readWord(char *bf) {
  char *cur = bf;
  *cur = getChar();
  while (*cur <= 32) *cur = getChar();
  while (*cur > 32) {
    ++cur;
    *cur = getChar();
  }
  return cur - bf;
}
inline int readInt() {
  int s = 1, c = readChar();
  int x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
static int write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = x;
}
inline void flush() {
  if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
}
inline void writeInt(long long x) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n--) writeChar(s[n]);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
int cnt_bit(int a) {
  int ans = 0;
  while (a) {
    if (a & 1) ++ans;
    a >>= 1;
  }
  return ans;
}
pair<int, int> ar[10];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> ar[i].first >> ar[i].second;
  double ans = 0;
  for (int mask = 1; mask < (1 << n); ++mask) {
    int l = -infi, r = infi;
    for (int i = 0; i < n; ++i) {
      if (mask & (1 << i)) l = max(l, ar[i].first), r = min(r, ar[i].second);
    }
    for (int cost = l; cost <= r; ++cost) {
      double p = 0;
      for (int top = 0; top < n; ++top) {
        if (mask & (1 << top)) continue;
        if (ar[top].second <= cost) continue;
        double d = min(1.0, (double)(ar[top].second - cost) /
                                (double)(ar[top].second - ar[top].first + 1));
        for (int i = 0; i < n; ++i) {
          if (i == top) continue;
          if (mask & (1 << i)) {
            d /= (double)(ar[i].second - ar[i].first + 1);
            continue;
          }
          if (ar[i].first >= cost)
            d = 0;
          else
            d *= min(1.0, (double)(cost - ar[i].first) /
                              (double)(ar[i].second - ar[i].first + 1));
        }
        p += d;
      }
      ans += p * cost;
    }
  }
  for (int mask = 1; mask < (1 << n); ++mask) {
    if (cnt_bit(mask) < 2) continue;
    int l = -infi, r = infi;
    for (int i = 0; i < n; ++i)
      if (mask & (1 << i)) l = max(l, ar[i].first), r = min(r, ar[i].second);
    for (int cost = l; cost <= r; ++cost) {
      double p = 1;
      for (int i = 0; i < n; ++i) {
        if (mask & (1 << i)) {
          p /= (double)(ar[i].second - ar[i].first + 1);
        } else {
          if (ar[i].first >= cost)
            p = 0;
          else
            p *= min(1.0, (double)(cost - ar[i].first) /
                              (double)(ar[i].second - ar[i].first + 1));
        }
      }
      ans += p * cost;
    }
  }
  cout.precision(20);
  cout << fixed;
  cout << ans;
  return 0;
}