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.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskC {
	private static final int N = 10005;
	double[][] pm;
	double[][] plm;
	double[][] e;

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int n = in.readInt();
		int[] l = new int[n];
		int[] r = new int[n];
		for (int i = 0; i < n; ++i) {
			l[i] = in.readInt();
			r[i] = in.readInt();
		}
		int m = 1 << n;
		pm = new double[m][];
		plm = new double[m][];
		e = new double[m][];
		for (int mask = 0; mask < m; ++mask) {
			pm[mask] = ArrayUtils.createArray(N, 0.0);
			plm[mask] = ArrayUtils.createArray(N, 0.0);
			e[mask] = ArrayUtils.createArray(N, 0.0);
		}
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < N; ++j) {
				if (j >= l[i] && j <= r[i]) {
					pm[1 << i][j] += 1.0 / (r[i] - l[i] + 1);
				}
			}
		}
		for (int mask = 1; mask < m; ++mask) {
			int i = 0;
			while ((mask & (1 << i)) == 0) ++i;
			int nmask = mask ^ (1 << i);
			if (nmask > 0) {
				for (int j = 1; j < N; ++j) {
					pm[mask][j] += pm[1 << i][j] * plm[nmask][j];
					pm[mask][j] += plm[1 << i][j - 1] * pm[nmask][j];
				}
			}
			for (i = 1; i < N; ++i) {
				plm[mask][i] += pm[mask][i];
				plm[mask][i] += plm[mask][i - 1];
			}
		}
		for (int mask = 1; mask < m; ++mask) {
			for (int i = 1; i < N; ++i) {
				e[mask][i] += i * pm[mask][i];
				e[mask][i] += e[mask][i - 1];
			}
		}
		double ans = 0;
		if (n == 1) {
			for (int a = l[0]; a <= r[0]; ++a) {
				for (int b = l[1]; b <= r[1]; ++b) {
					for (int c = l[2]; c <= r[2]; ++c) {
						int[] d = {a, b, c};
						Arrays.sort(d);
						ans += d[1] * 1.0 / (r[2] - l[2] + 1) / (r[1] - l[1] + 1) / (r[0] - l[0] + 1);
					}
				}
			}
		} else {
			for (int i = 1; i < N; ++i) {
				for (int mask = 1; mask < m; ++mask) {
					int nmask = (m - 1) ^ mask;
					double p = 1.0;
					for (int j = 0; j < n; ++j) {
						if ((mask & (1 << j)) > 0) {
							p *= pm[1 << j][i];
						}
					}
					if (nmask == 0) {
						ans += p * i;
					} else {
						if (Integer.bitCount(mask) == 1) {
							ans += e[nmask][i - 1] * p;
						} else {
							ans += p * plm[nmask][i - 1] * i;
						}
					}
				}
			}
		}
		out.printLine(ans);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}

}

class ArrayUtils {

	public static double[] createArray(int count, double value) {
		double[] array = new double[count];
		Arrays.fill(array, value);
		return array;
	}

}