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.awt.*;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicInteger;

import static java.lang.Math.*;

public class solver implements Runnable {
    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");
    String delim = " ";

    String readString() throws IOException {
        try {
            while (!tok.hasMoreTokens()) {
                tok = new StringTokenizer(in.readLine());
            }
            return tok.nextToken(delim);
        } catch (Exception e) {
            return null;
        }
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    Point readPoint() throws IOException {
        return new Point(readInt(), readInt());
    }

    // ----------------------------------

    int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    class Pair implements Comparable<Pair> {
        int a;
        int index;

        Pair(int a, int index) {
            this.a = a;
            this.index = index;
        }

        @Override
        public int compareTo(Pair o) {
            return a - o.a;
        }
    }

    boolean ok(int x, int y) {
        if (x > y) {
            int t = x;
            x = y;
            y = t;
        }
        if (x == 0) {
            if (y == 1)
                return true;
            return false;
        }
        if (x == 1)
            return true;
        return ok(x, y % x);
    }

    // ----------------------------------------

    int[] a;
    int n;
    ArrayList<String> list = new ArrayList<>();
    int max = 0;

    String getString() {
        String s = "";
        for (int i = 0; i < n; i++) {
            if (i != 0)
                s += " ";
            s += "" + a[i];
        }
        return s;
    }

    void brut(int pos) {
        if (pos == n) {
            int ans = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    int min = Integer.MAX_VALUE;
                    for (int k = i; k <= j; k++) {
                        min = Math.min(min, a[k]);
                    }
                    if (min != Integer.MAX_VALUE)
                        ans += min;
                }
            }
            if (ans > max) {
                max = ans;
                list.clear();
            }
            if (ans == max)
                list.add(getString());
            return;
        }

        for (int i = pos; i < n; i++) {
            int t = a[pos];
            a[pos] = a[i];
            a[i] = t;
            brut(pos + 1);
            t = a[pos];
            a[pos] = a[i];
            a[i] = t;
        }
    }

    String get(int n, int m) {
        int[] a = new int[n];
        boolean[] used = new boolean[n];

        int[] res = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = i + 1;
        }

        boolean chet = true;
        for (int i = 0; i < n / 2; i++) {
            int step2 = 1 << (n - i - 1);
            int index, index2;
            index = getIndex(step2, m);
            index2 = getIndex(step2, step2 - m + 1);
            // chet ^= true;
            if (chet) {
                res[i] = getNext(used, a, index);
                res[n - 1 - i] = getNext(used, a, index2);
            } else {
                res[n - 1 - i] = getNext(used, a, index2);
                res[i] = getNext(used, a, index);
            }
            // chet ^= true;
            if (m > step2 / 2)
                m -= step2 / 2;
        }

        int ost = -1;
        for (int i = 0; i < n; i++) {
            if (!used[i])
                ost = a[i];
        }
        if (ost != -1)
            res[n / 2] = ost;
        String s = "";
        for (int i = 0; i < n; i++) {
            if (i != 0)
                s += " ";
            s += "" + res[i];
        }
        return s;
    }

    int getNext(boolean[] used, int[] a, int index) {
        // int k = 0;
        // for (int j = 0; j < n; j++) {
        // if (used[j]) continue;
        // if (k == index) {
        // used[j] = true;
        // return a[j];
        // }
        // k++;
        // }
        // return 0;

        while (used[index])
            index++;
        used[index] = true;
        return a[index];
    }

    int getIndex(int step, int n) {
        if (n == 1 && step == 1)
            return 0;
        if (n <= step / 2)
            return 0;
        n -= step / 2;
        return 1 + getIndex(step / 2, n);
    }

    int getIndex2(int step, int n) {
        if (n == 1 && step == 1)
            return 0;
        if (n > step / 2)
            return 0;
        return 1 + getIndex2(step / 2, n);
    }

    boolean have(int mask, int bit) {
        return (mask & (1 << bit)) != 0;
    }

    boolean inRange(int i, int l, int r) {
        return i >= l && i <= r;
    }

    double verUpper(int i, int l, int r) {
        if (i > r)
            return 0;
        return 1d * (r - Math.max(l, i) + 1) / (r - l + 1);
    }

    double verLower(int i, int l, int r) {
        if (i < l)
            return 0;
        return 1d * (Math.min(i, r) - l + 1) / (r - l + 1);
    }

    double verIn(int i, int l, int r) {
        if (i < l || i > r)
            return 0;
        return 1d / (r - l + 1);
    }

    void solve() throws NumberFormatException, IOException {
        int n = readInt();
        int[] l = new int[n];
        int[] r = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = readInt();
            r[i] = readInt();
        }
        double answer = 0;
        for (int i = 1; i <= 10000; i++) {
            double ver = 0;
            int max = 1 << n;

            for (int w = 0; w < n; w++) {
                for (int mask = 1; mask < max; mask++) {
                    double p = verUpper(i + 1, l[w], r[w]);
                    int cnt = 0;
                    for (int pl = 0; pl < n; pl++) {
                        if (pl == w)
                            continue;
                        if (have(mask, pl)) {
                            cnt++;
                            p *= verIn(i, l[pl], r[pl]);
                        } else {
                            p *= verLower(i - 1, l[pl], r[pl]);
                        }
                    }
                    if (cnt > 0)
                        ver += p;
                }
            }
            ver /= 2;

            
            for (int mask = 1; mask < max; mask++) {
                double p = 1;
                int cnt = 0;
                for (int pl = 0; pl < n; pl++) {
                    if (have(mask, pl)) {
                        cnt++;
                        p *= verIn(i, l[pl], r[pl]);
                    } else {
                        p *= verLower(i - 1, l[pl], r[pl]);
                    }
                }
                if (cnt > 1) ver += p;
            }

            answer += i * ver;
        }
        out.println(answer);
    }

    // ----------------------------------------

    public static void main(String[] args) {
        new Thread(null, new solver(), "", 256 * (1L << 20)).start();
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();

            try {
                if (ONLINE_JUDGE) {
                    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");
                }
            } catch (Throwable e) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            }

            solve();
            out.close();

            timeEnd = System.currentTimeMillis();
            if (!ONLINE_JUDGE)
                System.err.println("Time = " + (timeEnd - timeBegin));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    long timeBegin, timeEnd;
}