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.BufferedReader;
import java.io.Reader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

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

class TaskC {
    private final FastScanner in;
    private final PrintWriter out;
    private int n;
    private int[] left;
    private int[] right;

    public TaskC(FastScanner in, PrintWriter out) {
        this.in = in;
        this.out = out;
    }

    public void solve(int testNumber) throws IOException {
        n = in.nextInt();

        left = new int[n];
        right = new int[n];

        for (int i = 0; i < n; i++) {
            left[i] = in.nextInt();
            right[i] = in.nextInt();
        }

        double ans = 0;
        for (int secondPrice = 1; secondPrice <= 10000; secondPrice++) {
            ans += secondPrice * prob(secondPrice);
        }
        
        out.println(ans);
    }

    private double prob(int secondPrice) {
        double prob = 0;

        for (int seconds = 1; seconds < (1<<n); seconds++) {
            int count = 0;
            for (int i = 0; i < n; i++) {
                if (BitUtils.isSet(seconds, i)) {
                    count++;
                }
            }

            for (int winner = 0; winner < n; winner++) {
                if (BitUtils.isSet(seconds, winner)) {
                    continue;
                }

                double p = 1.0;

                for (int i = 0; i < n; i++) {
                    if (i == winner) {
                        if (right[i] > secondPrice) {
                            p *= (double) (right[i] - Math.max(secondPrice + 1, left[i]) + 1) / (right[i] - left[i] + 1);
                        } else {
                            p = 0;
                        }
                    } else if (BitUtils.isSet(seconds, i)) {
                        if (left[i] <= secondPrice && right[i] >= secondPrice) {
                            p *= 1.0 / (right[i] - left[i] + 1);
                        } else {
                            p = 0;
                        }
                    } else {
                        if (left[i] < secondPrice) {
                            p *= (double) (Math.min(secondPrice - 1, right[i]) - left[i] + 1) / (right[i] - left[i] + 1);
                        } else {
                            p = 0;
                        }
                    }
                }

                prob += p;
            }

            if (count > 1) {
                double p = 1.0;

                for (int i = 0; i < n; i++) {
                    if (BitUtils.isSet(seconds, i)) {
                        if (left[i] <= secondPrice && right[i] >= secondPrice) {
                            p *= 1.0 / (right[i] - left[i] + 1);
                        } else {
                            p = 0;
                        }
                    } else {
                        if (left[i] < secondPrice) {
                            p *= (double) (Math.min(secondPrice - 1, right[i]) - left[i] + 1) / (right[i] - left[i] + 1);
                        } else {
                            p = 0;
                        }
                    }
                }

                prob += p;
            }
        }

        return prob;
    }
}

class FastScanner {
    private BufferedReader br;
    private String line = "";
    private int pos;

    public FastScanner(InputStream is) {
        this(new BufferedReader(new InputStreamReader(is)));
    }

    public FastScanner(Reader reader) {
        br = new BufferedReader(reader);
    }

    public int nextInt() throws IOException {
        if (!goToNextToken()) {
            return 0;
        }
        return readInt();
    }

    private boolean goToNextToken() throws IOException {
        if (br == null) {
            return false;
        }

        while (pos == line.length()) {
            line = br.readLine();

            if (line == null) {
                br = null;
                return true;
            }

            pos = 0;

            skipWhitespace();
        }

        return true;
    }

    private int readInt() {
        int result = 0;

        int sign = 1;
        if (line.charAt(pos) == '-') {
            sign = -1;

            pos++;
        }

        while (pos < line.length()) {
            char c = line.charAt(pos++);

            if (c == ' ' || c == '\t') {
                break;
            }

            result *= 10;
            result += c - '0';
        }

        skipWhitespace();

        return sign * result;
    }

    private void skipWhitespace() {
        while (pos < line.length()) {
            char c = line.charAt(pos);

            if (c != ' ' && c != '\t') {
                break;
            }

            pos++;
        }
    }
}

class BitUtils {
    public static boolean isSet(long number, int index) {
        if (index < 0 || index > 62) {
            throw new IndexOutOfBoundsException();
        }
        return (number & (1L << index)) != 0;
    }
}