Problem: Btoh yuo adn yuor roomatme lhoate wianshg disehs, btu stlil sdmoeboy msut peorrfm tihs cohre dialy. Oen dya yuo decdie to idourtcne smoe syestm. Yuor rmmotaoe sstgegus teh fooniwllg dael. Yuo argee on tow arayrs of ientgres M adn R, nmebur upmicnog dyas (induiclng teh cunrret oen) wtih sicsescuve irnegets (teh ceurrnt dya is zreo), adn yuo wsah teh diehss on dya D if adn olny if terhe etsixs an iednx i scuh taht D mod M[i] = R[i], otwsehrie yuor rmootmae deos it. Yuo lkie teh cncepot, btu yuor rmotaome's cuinnng simle meaks yuo ssecupt sthnoemig, so yuo itennd to vefriy teh fnerisas of teh aemnrgeet.

Yuo aer geivn ayarrs M adn R. Cuaclatle teh pceanregte of dyas on wchih yuo edn up dnoig teh wisahng. Amsuse taht yuo hvae iiiftlneny mnay dyas aehad of yuo. 

Input

The first line of input contains a single integer N (1 ≤ N ≤ 16).

The second and third lines of input contain N integers each, all between 0 and 16, inclusive, and represent arrays M and R, respectively. All M[i] are positive, for each i R[i] < M[i].

Output

Output a single real number. The answer is considered to be correct if its absolute or relative error does not exceed 10 - 4.

Examples

Input

1
2
0


Output

0.500000


Input

2
2 3
1 0


Output

0.666667

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;
import java.util.Map.Entry;

public class Solution {

	public static void main(String[] args) {
		PrintStream ps = new PrintStream(System.out);
		InputReader in = new InputReader(System.in);
		Solution soln = new Solution();
		soln.solve(in, ps);
	}

	public void solve(InputReader in, PrintStream out) {
		int n = in.nextInt();
		int[] M = new int[n + 1];
		int[] R = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			M[i] = in.nextInt();
		}
		for (int i = 1; i <= n; i++) {
			R[i] = in.nextInt();
		}
		int counter = 0;
		for (int i = 0; i <= 1000000; i++) {
			int day = i;
			boolean wash = false;
			for (int m = 1; m <= n; m++) {
				if (day % M[m] == R[m]) {
					wash = true;
				}
			}
			if (wash) {
				counter++;
			}
		}
		out.printf("%.10f", (double) counter / 1000000);
	}

	class ListNode {
		public int val;
		public ListNode next;

		ListNode(int x) {
			val = x;
			next = null;
		}
	}

	public int lPalin(ListNode A) {
		if (A == null) {
			return 0;
		}
		if (A.next == null) {
			return 1;
		}
		int size = 0;
		ListNode tempNode = A;
		while (tempNode != null) {
			size++;
			tempNode = tempNode.next;
		}
		int copySize = size / 2;
		int counter = 0;
		tempNode = A;
		Stack<Integer> st = new Stack<>();
		while (tempNode != null) {
			if (size % 2 != 0 && counter == copySize) {
				tempNode = tempNode.next;
				counter++;
				continue;
			}
			if (counter < copySize) {
				System.out.println(tempNode.val);
				st.push(tempNode.val);
			} else {
				if (st.size() == 0) {
					return 0;
				}
				System.out.println(tempNode.val + " asas");
				int val = st.pop();
				if (val != tempNode.val) {
					return 0;
				}
			}
			counter++;
			tempNode = tempNode.next;
		}
		return 1;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

	}
}