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.*;

public class C {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	class State implements Comparable<State> {
		int l;
		int r;

		State(int l, int r) {
			this.l = l;
			this.r = r;
		}

		public int compareTo(State s) {
			return l - s.l;
		}
	}
	
	double probMoreOrEq(int min, int max, int moreOrEq)	 {
		if (moreOrEq > max) {
			return 0;
		} else if (moreOrEq <= min) {
			return 1;
		}
		return (max - moreOrEq + 1) / (max - min + 1.0);
	}
	
	double probLessOrEq(int min, int max, int lessOrEq) {
		return 1.0 - probMoreOrEq(min, max, lessOrEq + 1);
	}
	
	public void run() {
		int n = in.nextInt();
		int[] l = new int[n];
		int[] r = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = in.nextInt();
			r[i] = in.nextInt();
		}
		
		/* god
		double res = 0;
		final int MAX = 10123;
		for (int value = 0; value <= MAX; value++) {
			for (int winner = 0; winner < n; winner++) {
				for (int second = 0; second < n; second++) {
					if (second == winner) continue;
					if (l[second] > value || r[second] < value) continue;
					
					double pr = 1.0 / (r[second] - l[second] + 1.0);
					for (int k = 0; k < n; k++) {
						if (k == second) continue;
						if (k == winner) {
							if (winner > second) {
								pr *= probMoreOrEq(l[k], r[k], value);
							} else {
								pr *= probMoreOrEq(l[k], r[k], value + 1);
							}
						} else {
							if (k < second) {
								pr *= probLessOrEq(l[k], r[k], value);
							} else {
								pr *= probLessOrEq(l[k], r[k], value - 1);
							}
						}
					}
					res += pr * value;
				}
			}
		}
		System.out.println(res);
		*/
		
		/* naive (n=3)
		double all = 1;
		for (int i = 0; i < n; i++) {
			all *= (r[i] - l[i] + 1);
		}
		
		int[][] cnt = new int[3][6];
		double res = 0;
		for (int i = l[0]; i <= r[0]; i++) {
			for (int j = l[1]; j <= r[1]; j++) {
				for (int k = l[2]; k <= r[2]; k++) {
					int[] a = {i, j, k};
					Arrays.sort(a);
					res += a[1] / all;
					if (i == a[1])
						cnt[0][a[1]]++;
					else if (j == a[1]) 
						cnt[1][a[1]]++;
					else
						cnt[2][a[1]]++;
				}
			}
		}
		for (int i = 0; i < cnt.length; i++)
			System.out.println(Arrays.toString(cnt[i]));
		System.out.println(res);
	
		*/
		
		double all = 1;
		for (int i = 0; i < n; i++) {
			all *= (r[i] - l[i] + 1);
		}
		
		double res = 0;
		for (int i = 0; i < n; i++) {
			for (int secondVal = l[i]; secondVal <= r[i]; secondVal++) {
				double sum = 0;
				for (int j = 0; j < n; j++) if (i != j) {
					double tmp = 1.0 / all;
					for (int k = 0; k < n; k++) if (i != k) {
						int rate = 0;
						if (j != k) {
							if (l[k] > secondVal)
								rate = 0;
							else if (r[k] < secondVal)
								rate = r[k] - l[k] + 1;
							else
								rate = Math.max(0, Math.min(r[k], secondVal) - l[k] + (i > k ? 1 : 0));
						}
						else {
							if (r[k] < secondVal)
								rate = 0;
							else if (l[k] > secondVal)
								rate = r[k] - l[k] + 1;
							else
								rate = Math.max(0, r[k] - Math.max(l[k], secondVal) + (i > k ? 0 : 1));
						}
//						System.out.println(j + " " + k + " " + rate);
						tmp *= rate;
					}
					sum += tmp;
				}
//				System.out.println(i + " " + secondVal + " " + sum);
				res += (sum * secondVal);
			}
		}
		System.out.println(res);
		
		out.close();
	}

	public static void main(String[] args) {
		new C().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		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++];
		}

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

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

		int[][] nextIntMap(int n, int m) {
			int[][] map = new int[n][m];
			for (int i = 0; i < n; i++) {
				map[i] = in.nextIntArray(m);
			}
			return map;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

		long[][] nextLongMap(int n, int m) {
			long[][] map = new long[n][m];
			for (int i = 0; i < n; i++) {
				map[i] = in.nextLongArray(m);
			}
			return map;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		double[][] nextDoubleMap(int n, int m) {
			double[][] map = new double[n][m];
			for (int i = 0; i < n; i++) {
				map[i] = in.nextDoubleArray(m);
			}
			return map;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}