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.IOException;
import java.math.BigDecimal;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {

    int n;
    boolean[] vis;
    int[][] grid;


    final int MAX_SIZE = 10000;
    public void solve(int testNumber, InputReader jin, PrintWriter jout) {
        n = jin.int32();

        int[] l = new int[n];
        int[] r = new int[n];

        BigDecimal den = new BigDecimal("1");
        for(int i = 0; i < n; i++) {
            l[i] = jin.int32();
            r[i] = jin.int32();
            den = den.multiply(BigDecimal.valueOf(r[i] - l[i] + 1));
        }

        //jout.println(den);

        vis = new boolean[n];
        grid = new int[n][10001];
        for(int i = 0; i < n; i++) {
            for(int j = l[i]; j <= MAX_SIZE; j++) {
                grid[i][j] = (j <= r[i]? 1: 0) + grid[i][j - 1];
            }
        }


        BigDecimal t1 = BigDecimal.ZERO;
        for(int w = 1; w <= 10000; w++) {
            BigDecimal tt1 = solve1(w);
            BigDecimal tt2 = solve2(w);
            BigDecimal tt3 = tt1.add(tt2);
            //if(tt3.compareTo(BigDecimal.ZERO) > 0) jout.println(w + " " + tt3);
            t1 = t1.add(tt1.add(tt2).multiply(BigDecimal.valueOf(w)));

        }
        jout.printf("%.10f", t1.divide(den, 9, BigDecimal.ROUND_HALF_UP));
    }

    private BigDecimal solve2(int w) {
        BigDecimal t1 = BigDecimal.ZERO;
        for(int mask1 = 0; mask1 < (1 << n); mask1++) {
            if(Integer.bitCount(mask1) <= 1) continue;
            boolean valid = true;
            for(int i = 0; i < n; i++) {
                if((mask1 & (1 << i)) == 0) continue;
                valid &= (grid[i][w] - grid[i][w - 1]) > 0;
            }
            if(valid) {
                BigDecimal t2 = BigDecimal.ZERO;
                for(int mask2 = 0; mask2 < (1 << n); mask2 = mask2 == 0? 1: mask2 << 1) {
                    if((mask1 & mask2) > 0) continue;
                    BigDecimal t3 = BigDecimal.ONE;
                    for(int t = 0; t < n; t++) {
                        if((mask1 & (1 << t)) > 0) continue;
                        if((mask2 & (1 << t)) > 0) {
                            t3 = t3.multiply(BigDecimal.valueOf(grid[t][MAX_SIZE] - grid[t][w]));
                        } else {
                            t3 = t3.multiply(BigDecimal.valueOf(grid[t][w - 1]));
                        }
                    }
                    t2 = t2.add(t3);
                }
                t1 = t1.add(t2);
            }

        }
        return t1;
    }

    public BigDecimal solve1(int w) {
        BigDecimal t2 = BigDecimal.ZERO;
        for(int t = 0; t < n; t++) {
            if(grid[t][w] - grid[t][w - 1] == 0) continue;
            BigDecimal t3 = BigDecimal.ZERO;
            for (int mask = 1; mask < (1 << n); mask <<= 1) {
                if((mask & (1 << t)) > 0) continue;
                BigDecimal t4 = BigDecimal.ONE;
                for(int tt = 0; tt < n; tt++) {
                    if(tt == t) continue;
                    if((mask & (1 << tt)) > 0) {
                        t4 = t4.multiply(BigDecimal.valueOf(grid[tt][MAX_SIZE] - grid[tt][w]));
                    } else {
                        t4 = t4.multiply(BigDecimal.valueOf(grid[tt][w - 1]));
                    }
                }
                t3 = t3.add(t4);
            }
            t2 = t2.add(t3);
        }
        return t2;
    }

}

class InputReader {
    private static final int bufferMaxLength = 1024;
    private InputStream in;
    private byte[] buffer;
    private int currentBufferSize;
    private int currentBufferTop;
    private static final String tokenizers = " \t\r\f\n";

    public InputReader(InputStream stream) {
        this.in = stream;
        buffer = new byte[bufferMaxLength];
        currentBufferSize = 0;
        currentBufferTop = 0;
    }

    private boolean refill() {
        try {
            this.currentBufferSize = this.in.read(this.buffer);
            this.currentBufferTop = 0;
        } catch(Exception e) {}
        return this.currentBufferSize > 0;
    }


    public Byte readChar() {
        if(currentBufferTop < currentBufferSize) {
            return this.buffer[this.currentBufferTop++];
        } else {
            if(!this.refill()) {
                return null;
            } else {
                return readChar();
            }
        }
    }

    public String token()  {
        StringBuffer tok = new StringBuffer();
        Byte first;
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) != -1));
        if(first == null) return null;
        tok.append((char)first.byteValue());
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) == -1)) {
            tok.append((char)first.byteValue());
        }
        return tok.toString();
    }


    public String next() {
        return token();
    }

    public Integer int32() throws NumberFormatException {
        String tok = token();
        return tok == null? null : Integer.parseInt(tok);
    }

    public Long int64() throws NumberFormatException {
        String tok = token();
        return tok == null? null : Long.parseLong(tok);
    }
}