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 JAVA):

Solution:
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main{
    final boolean isFileIO =  false;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");
    String delim = " ";

    public static void main(String[] args) throws IOException {
        Main m = new Main();
        m.initIO();
        m.solve();
        m.in.close();
        m.out.close();
    }

    public void initIO() throws IOException {
        if(!isFileIO) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt"); 
        }
    }
  
    String nt() throws IOException {
        if(!st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken(delim);
    }

    String rl() throws IOException {
        return in.readLine();
    }

    int ni() throws IOException {
        return Integer.parseInt(nt());
    }

    long nl() throws IOException {
        return Long.parseLong(nt());
    }

    double nd() throws IOException {
        return Double.parseDouble(nt());
    }
    
    class Pair {
        public int x, y;
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public void solve() throws IOException {
        int n = ni();
        int[] l = new int[n];
        int[] r = new int[n];
        int max = 0;
        for(int i = 0; i < n; i++) {
            l[i] = ni(); r[i] = ni();
            max = Math.max(r[i], max);
        }
        double res = 0.0;
        int max_mask = (1 << n);
        for(int i = 1; i <= max; i++) {
            for(int j = 1; j < max_mask; j++) {
                boolean isFine = true;
                double prob = 1.0;
                for(int z = 0; z < n; z++) {
                    if((j & (1 << z)) == (1 << z)) {
                        if(i < l[z] || i > r[z]) {
                            isFine = false;
                        }
                        prob *= 1.0 / (r[z] - l[z] + 1);
                    }
                }
                if(!isFine) {
                    continue;
                }
                
                for(int z = 0; z < n; z++) {
                    double prob2 = 1.0;
                    if((j & (1 << z)) == 0) {
                        if(r[z] <= i) {
                            continue;
                        }
                        isFine = true;
                        for(int k = 0; k < n; k++) {
                            if(k == z) { continue; }
                            if((j & (1 << k)) == 0) {
                                if(l[k] >= i) {
                                    isFine = false;
                                }
                                prob2 *= 1.0 * (Math.min(i, r[k] + 1) - l[k]) / (r[k] - l[k] + 1);
                            }
                        }
                        
                        if(!isFine) {
                            continue;
                        }
                        res += i * prob * prob2 * (r[z] - Math.max(i, l[z] - 1)) / (r[z] - l[z] + 1);
                    }
                }
                double prob2 = 1.0;
                isFine = true;
                int cnt = 0;
                for(int z = 0; z < n; z++) {
                    if((j & (1 << z)) == 0) {
                        if(l[z] >= i) {
                            isFine = false;
                        }
                        prob2 *= 1.0 * (Math.min(r[z] + 1, i) - l[z]) / (r[z] - l[z] + 1);
                    } else {
                        cnt++;
                    }
                }
                if(isFine && cnt != 1) {
                    res += i * prob * prob2;
                }
            }
        }
        out.println(res);
    }
}

class Utils {

    public static long binpow(long a, long exp, long mod) {
        if(exp == 0) {
            return 1;
        }
        if(exp % 2 == 0) {
            long temp = binpow(a, exp / 2, mod);
            return (temp * temp) % mod;
        } else {
            return (binpow(a, exp - 1, mod) * a) % mod;
        }
    }

    public static long inv(long a, long mod) {
        return binpow(a, mod - 2, mod);
    }

    public static long addmod(long a, long b, long mod) {
        return ((a + b) % mod + mod) % mod;
    }

    public static long gcd(long a, long b) {
        if(b == 0)
            return a;
        return gcd(b, a % b);
    }

    //mul must be < 10^18
    public static long mulmod(long a, long b, long mod) {
        return (a * b + (((a * b) / mod) + 1) * mod) % mod;
    }
}