Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on n - 2 intermediate planets. Formally: we number all the planets from 1 to n. 1 is Earth, n is Mars. Natasha will make exactly n flights: 1 → 2 → … n → 1.

Flight from x to y consists of two phases: take-off from planet x and landing to planet y. This way, the overall itinerary of the trip will be: the 1-st planet → take-off from the 1-st planet → landing to the 2-nd planet → 2-nd planet → take-off from the 2-nd planet → … → landing to the n-th planet → the n-th planet → take-off from the n-th planet → landing to the 1-st planet → the 1-st planet.

The mass of the rocket together with all the useful cargo (but without fuel) is m tons. However, Natasha does not know how much fuel to load into the rocket. Unfortunately, fuel can only be loaded on Earth, so if the rocket runs out of fuel on some other planet, Natasha will not be able to return home. Fuel is needed to take-off from each planet and to land to each planet. It is known that 1 ton of fuel can lift off a_i tons of rocket from the i-th planet or to land b_i tons of rocket onto the i-th planet. 

For example, if the weight of rocket is 9 tons, weight of fuel is 3 tons and take-off coefficient is 8 (a_i = 8), then 1.5 tons of fuel will be burnt (since 1.5 ⋅ 8 = 9 + 3). The new weight of fuel after take-off will be 1.5 tons. 

Please note, that it is allowed to burn non-integral amount of fuel during take-off or landing, and the amount of initial fuel can be non-integral as well.

Help Natasha to calculate the minimum mass of fuel to load into the rocket. Note, that the rocket must spend fuel to carry both useful cargo and the fuel itself. However, it doesn't need to carry the fuel which has already been burnt. Assume, that the rocket takes off and lands instantly.

Input

The first line contains a single integer n (2 ≤ n ≤ 1000) — number of planets.

The second line contains the only integer m (1 ≤ m ≤ 1000) — weight of the payload.

The third line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 1000), where a_i is the number of tons, which can be lifted off by one ton of fuel.

The fourth line contains n integers b_1, b_2, …, b_n (1 ≤ b_i ≤ 1000), where b_i is the number of tons, which can be landed by one ton of fuel. 

It is guaranteed, that if Natasha can make a flight, then it takes no more than 10^9 tons of fuel.

Output

If Natasha can fly to Mars through (n - 2) planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number -1.

It is guaranteed, that if Natasha can make a flight, then it takes no more than 10^9 tons of fuel.

The answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}. Formally, let your answer be p, and the jury's answer be q. Your answer is considered correct if \frac{|p - q|}{max{(1, |q|)}} ≤ 10^{-6}.

Examples

Input

2
12
11 8
7 5


Output

10.0000000000


Input

3
1
1 4 1
2 5 3


Output

-1


Input

6
2
4 6 3 3 5 6
2 6 3 6 5 3


Output

85.4800000000

Note

Let's consider the first example.

Initially, the mass of a rocket with fuel is 22 tons.

  * At take-off from Earth one ton of fuel can lift off 11 tons of cargo, so to lift off 22 tons you need to burn 2 tons of fuel. Remaining weight of the rocket with fuel is 20 tons.
  * During landing on Mars, one ton of fuel can land 5 tons of cargo, so for landing 20 tons you will need to burn 4 tons of fuel. There will be 16 tons of the rocket with fuel remaining.
  * While taking off from Mars, one ton of fuel can raise 8 tons of cargo, so to lift off 16 tons you will need to burn 2 tons of fuel. There will be 14 tons of rocket with fuel after that.
  * During landing on Earth, one ton of fuel can land 7 tons of cargo, so for landing 14 tons you will need to burn 2 tons of fuel. Remaining weight is 12 tons, that is, a rocket without any fuel.



In the second case, the rocket will not be able even to take off from Earth.

Difficulty: MEDIUM
Tags: Sorting

Mathematics
Skill types: Sorting

Starter code:

Solutions:
from sys import stdin
n = int(stdin.readline())
m = int(stdin.readline())
A = list(map(int, stdin.readline().split()))
B = list(map(int, stdin.readline().split()))
if 1 in A or 1 in B:
	print(-1)
else:
	ans = m * B[0] / (B[0] - 1)
	for i in range(n - 1, 0, -1):
		ans = ans * A[i] / (A[i] - 1)
		ans = ans * B[i] / (B[i] - 1)
	ans = ans * A[0] / (A[0] - 1)
	print(float(str(round(ans - m, 10))))


def read():
	return int(input())

def readmap():
	return map(int, input().split())

def readlist():
	return list(map(int, input().split()))

def coef(c, d):
	return c + (1 - c) / d
n = read()
m = read()
A = readlist()
B = readlist()
c = 0
c = coef(c, A[0])
for i in range(1, n):
	c = coef(c, B[i])
	c = coef(c, A[i])
c = coef(c, B[0])
if c < 1:
	print(m * c / (1 - c))
else:
	print(-1)


def check(m1):
	for i in range(n):
		if i == 0:
			m1 -= (m + m1) / a[i]
			if m1 < 0:
				return 0
		elif i == n - 1:
			m1 -= (m + m1) / b[i]
			if m1 < 0:
				return 0
		else:
			m1 -= (m + m1) / b[i]
			if m1 < 0:
				return 0
			m1 -= (m + m1) / a[i]
			if m1 < 0:
				return 0
	m1 -= (m + m1) / a[n - 1]
	if m1 < 0:
		return 0
	m1 -= (m + m1) / b[0]
	if m1 < 0:
		return 0
	return 1
n = int(input())
m = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
l = 0
r = 1000000000.0 + 1
eps = 1e-06
while r - l > eps:
	med = (l + r) / 2
	if check(med):
		r = med
	else:
		l = med
if check(l):
	print(round(l, 6))
elif check(r):
	print(round(r, 6))
else:
	print(-1)


from math import *
import sys
input = sys.stdin.readline

def can(a, b, mass, fuel):
	fuel -= (mass + fuel) / a[0]
	if fuel < 0.0:
		return False
	for i in range(1, len(b)):
		fuel -= (mass + fuel) / b[i]
		if fuel < 0.0:
			return False
		fuel -= (mass + fuel) / a[i]
		if fuel < 0.0:
			return False
	fuel -= (mass + fuel) / b[0]
	return fuel >= 0.0

def main():
	planets = int(input())
	mass = int(input())
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	if 1 in a or 1 in b:
		print(-1)
		return
	low = 0.0
	high = 1500000000.0
	for i in range(60):
		mid = (low + high) / 2.0
		if can(a, b, mass, mid):
			high = mid
		else:
			low = mid
	print(high)
main()


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
n = int(input())
m = int(input())
a = list(map(int, sys.stdin.readline().split(' ')))
b = list(map(int, sys.stdin.readline().split(' ')))
if 1 in b:
	print(-1)
elif 1 in a:
	print(-1)
else:
	ans = m / (b[0] - 1) + m
	i = n - 1
	while i >= 1:
		ans = ans + ans / (a[i] - 1)
		ans = ans + ans / (b[i] - 1)
		i -= 1
	ans += ans / (a[0] - 1)
	print(ans - m)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


m = int(input())
ini = int(input())
temp = ini
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for i in range(m - 1, -1, -1):
	if b[(i + 1) % m] == 1 or a[i] == 1:
		ini = temp - 1
		break
	ini = ini + ini / (b[(i + 1) % m] - 1)
	ini = ini + ini / (a[i] - 1)
print(ini - temp)


def predicate(x, m, a):
	rhs = 0
	for i in range(len(a)):
		cv = (m + (x - rhs)) / a[i]
		if cv < -5e-07:
			return False
		rhs += cv
	if x - rhs >= -5e-07:
		return True
	return False
n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(n - 1):
	c.append(a[i])
	c.append(b[i + 1])
c.append(a[-1])
c.append(b[0])
lo = 0
hi = 10000000000.0
i = 0
while i < 100:
	mid = (hi + lo) / 2
	if predicate(mid, m, c):
		hi = mid
	else:
		lo = mid
	i += 1
print(lo) if lo <= 1000000000.0 + 5e-07 else print(-1)


n = int(input())
m = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
if b[0] == 1 or a[0] == 1:
	print(-1)
	exit(0)
ans = m / (b[0] - 1)
for i in range(n - 1, 0, -1):
	if b[i] == 1 or a[i] == 1:
		print(-1)
		exit(0)
	ans += (m + ans) / (a[i] - 1)
	ans += (m + ans) / (b[i] - 1)
print((m + ans) / (a[0] - 1) + ans)


n = int(input())
m = int(input())
a = []
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
a += b
z = 1
for i in range(2 * n):
	z = z * (1 - 1 / a[i])
if z != 0:
	ans = m * (1 / z)
else:
	ans = -1
if ans >= m:
	print(ans - m)
else:
	print(-1)


n = int(input())
mass = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
a.append(a[0])
b.append(b[0])

def can(f):
	for i in range(len(a) - 1):
		f -= (mass + f) / a[i]
		if f < 0:
			return False
		f -= (mass + f) / b[i + 1]
		if f < 0:
			return False
	return True
left = 0
right = 10000000000
for i in range(200):
	mid = (left + right) / 2
	if can(mid):
		right = mid
	else:
		left = mid
EPS = 1e-06
if abs(left - 10000000000) < EPS:
	print(-1)
else:
	print(left)


import math

def main():
	n = int(input())
	m = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	if 1 in a or 1 in b:
		print(-1)
	else:
		answer = m * math.exp(sum([math.log(1 + 1 / (x - 1)) for x in a + b]))
		print(answer - m)
main()


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = m
for i in range(n):
	if b[-i] != 1:
		e = ans / (b[-i] - 1)
		ans += e
		if a[n - i - 1] != 1:
			e = ans / (a[n - i - 1] - 1)
			ans += e
		else:
			print(-1)
			exit()
	else:
		print(-1)
		exit()
print(ans - m)


n = int(input())
m = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
s = 0
for i in range(n):
	s += (1 - s) / a[i]
	s += (1 - s) / b[(i + 1) % n]
if 0 < s < 1:
	print(s * m / (1 - s))
else:
	print(-1)


from itertools import chain
n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = m
cont = 1
for x in chain(a, b):
	if cont == 1:
		if x == 1:
			cont = 2
		else:
			res /= 1 - 1 / x
if cont == 1:
	print(res - m)
else:
	print('-1')


n = int(input())
m = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
flag = 1
for i in range(n):
	if a[i] == 1 or b[i] == 1:
		print(-1)
		flag = 0
		break
if flag:
	wt = m
	wt += wt / (b[0] - 1)
	for i in range(n - 1, 0, -1):
		wt += wt / (a[i] - 1)
		wt += wt / (b[i] - 1)
	wt += wt / (a[0] - 1)
	print(wt - m)


def scanf(obj=list, type=int, sep=' '):
	return obj(map(type, input().split(sep)))
(n,) = scanf()
(m,) = scanf()
a = scanf()
b = scanf()
if a.count(1) or b.count(1):
	print(-1)
	quit()
(l, r) = (0, 10 ** 9)

def f(x):
	for (ai, bi) in zip(a, b):
		if ai * x < m + x:
			return False
		x -= (m + x) / ai
		if bi * x < m + x:
			return False
		x -= (m + x) / bi
	return True
while r - l > 1e-06:
	temp = (r + l) / 2
	if f(temp):
		r = temp
	else:
		l = temp
print(r)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = 0.0
r = 2000000000.0
cnt = 0
while cnt < 100:
	c = (l + r) / 2
	w = c + m
	f = True
	for i in range(n):
		w -= w / a[i]
		if w < m:
			f = False
			break
		w -= w / b[(i + 1) % n]
		if w < m:
			f = False
			break
	if f:
		r = c
	else:
		l = c
	cnt += 1
if r < 1500000000.0:
	print('%.10f' % r)
else:
	print(-1)


n = int(input())
m = int(input())
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
if 1 in a:
	print(-1)
elif 1 in b:
	print(-1)
else:
	c = float(1)
	for i in range(n):
		c = c * (a[i] - 1) * (b[i] - 1) / (a[i] * b[i])
	print(m / c - m)


def getUsefulWeight(coef, uw):
	if coef == 1:
		print(-1)
		exit(0)
	uw += uw / (coef - 1)
	return uw
n = int(input().strip())
m = float(input().strip())
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
uw = m
coef = b[0]
uw = getUsefulWeight(coef, uw)
for i in range(len(a) - 1, 0, -1):
	coef = a[i]
	uw = getUsefulWeight(coef, uw)
	coef = b[i]
	uw = getUsefulWeight(coef, uw)
coef = a[0]
uw = getUsefulWeight(coef, uw)
print(uw - m)


(n, m) = (int(input()), int(input()))
m1 = m
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if 1 in set(a) or 1 in set(b):
	print(-1)
else:
	for i in a + b:
		m *= i / (i - 1)
	print(m - m1)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
L = -1
R = 1000000000.0 + 179

def check(w):
	w += m
	for i in range(len(a)):
		if w - w / a[i] >= m:
			w -= w / a[i]
		else:
			return False
		if w - w / b[i] >= m:
			w -= w / b[i]
		else:
			return False
	return True
for temp in range(100):
	mid = (L + R) / 2
	if check(mid):
		R = mid
	else:
		L = mid
if R > 1000000000.0 + 1:
	print(-1)
else:
	template = '{:.' + str(10) + 'f}'
	print(template.format(R))


(N, M) = (int(input()), int(input()))
(u, d) = ([*map(int, input().split())], [*map(int, input().split())])
if d[0] == 1:
	print(-1)
	exit(0)
need = M / (d[0] - 1)
if need <= 0:
	print(-1)
	exit(0)
for i in range(N - 1, 0, -1):
	if u[i] == 1:
		print(-1)
		exit(0)
	need = (M + need * u[i]) / (u[i] - 1)
	if need <= 0:
		print(-1)
		exit(0)
	if d[i] == 1:
		print(-1)
		exit(0)
	need = (M + need * d[i]) / (d[i] - 1)
	if need <= 0:
		print(-1)
		exit(0)
if u[0] == 1:
	print(-1)
	exit(0)
need = (M + need * u[0]) / (u[0] - 1)
if need <= 0:
	print(-1)
	exit(0)
print('%.15f' % need)


n = eval(input())
m = eval(input())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
flag = 0
for i in range(1, n + 1):
	if a[i] <= 1:
		flag = 1
for i in range(1, n + 1):
	if b[i] <= 1:
		flag = 1
l = 0
r = 1000000000.0
if flag == 1:
	print(-1)
else:
	m1 = m
	l = m1 * b[1] / (b[1] - 1)
	for i in range(n, 1, -1):
		m1 = l
		l = m1 * a[i] / (a[i] - 1)
		m1 = l
		l = m1 * b[i] / (b[i] - 1)
	m1 = l
	l = m1 * a[1] / (a[1] - 1)
	print('%.10f' % (l - m))


n = int(input())
m = int(input())
go = [int(e) for e in input().split(' ')]
land = [int(e) for e in input().split(' ')]
if 1 in go + land:
	print(-1)
	exit()
ans = m + m / (land[0] - 1)
for k in range(-1, -n, -1):
	ans += ans / (go[k] - 1)
	ans += ans / (land[k] - 1)
ans += ans / (go[0] - 1)
print(ans - m)


(n,) = list(map(int, input().split()))
(m,) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(b[0])
b = b[1:]
if 1 in a:
	print(-1)
	exit()
if 1 in b:
	print(-1)
	exit()
fuel = 0
for i in range(n - 1, -1, -1):
	fuel = (fuel + m * (1 / a[i] + 1 / b[i] - 1 / (a[i] * b[i]))) / (1 - 1 / a[i] - 1 / b[i] + 1 / (a[i] * b[i]))
print(fuel)


import sys
n = int(input())
m = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
l = a + b
if 1 in l:
	print(-1)
	sys.exit()
ans = 1
num = 1
denum = 1
c = 0
for i in range(len(l)):
	num *= l[i] - 1
	denum *= l[i]
	c += 1
	if c % 20 == 0 or i == len(l) - 1:
		ans *= num / denum
		num = 1
		denum = 1
res = m * (1 - ans) / ans
print(res)


n = int(input())
k = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def prov(x):
	for u in range(n):
		ans = (k + x) / a[u]
		x -= ans
		if x <= 0:
			return 0
		ans = (k + x) / b[u]
		x -= ans
		if x <= 0:
			return 0
	return 1
l = 0
r = 1000000000.0 + 1
for i in range(1000):
	m = (l + r) / 2
	if prov(m):
		r = m
	else:
		l = m
EPS = 1e-06
if abs(1000000000.0 + 1 - l) < EPS:
	print(-1)
else:
	print(l)


n = int(input())
m = int(input())
a = [int(aa) for aa in input().split()]
b = [int(bb) for bb in input().split()]
if 1 in a or 1 in b:
	print(-1)
	exit(0)
c = 0
for count in range(2 * n, 0, -1):
	id = (count // 2 + 1) % n
	if count % 2 == 0:
		c = (c * b[id] + m) / (b[id] - 1)
	else:
		c = (c * a[id] + m) / (a[id] - 1)
print(c)


n = int(input())
m = int(input())
import sys
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(b[0])
b.pop(0)
mas = m
for i in range(len(a) - 1, -1, -1):
	if b[i] <= 1:
		mas = -1
		break
	mas += mas / (b[i] - 1)
	if a[i] <= 1:
		mas = -1
		break
	mas += mas / (a[i] - 1)
if mas == -1:
	print(-1)
else:
	print(mas - m)


import math
import itertools
getInputList = lambda : list(input().split())
getInputIntList = lambda : list(map(int, input().split()))
n = int(input())
m = int(input())
a = getInputIntList()
b = getInputIntList()
w = a + b
left = 0
right = 10 ** 9 + 2
best = -1
iteration = 500
while abs(left - right) >= 1 / 10 ** 9:
	md = (left + right) / 2
	iw = md + m
	for i in w:
		iw -= iw / i
	if iw >= m:
		best = md
		right = md - 1
	else:
		left = md + 1
	iteration -= 1
	if iteration == 0:
		break
print(best)


n = int(input())
rm = m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if min(a + b) is 1:
	print(-1)
else:
	for i in range(n - 1, -1, -1):
		m += m / (a[(i + 1) % n] - 1)
		m += m / (b[i] - 1)
	print(round(m - rm, 7))


n = int(input())
m = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
p = []
p.append(a[0])
for i in range(1, n):
	p.append(b[i])
	p.append(a[i])
p.append(b[0])
p.reverse()
t = []
t.append(0)
able = True
for i in range(1, 2 * n):
	if p[i - 1] == 1:
		able = False
		break
	else:
		t.append((m + p[i - 1] * t[i - 1]) / (p[i - 1] - 1))
lp = p[2 * n - 1]
if lp == 1:
	print(-1)
elif not able:
	print(-1)
else:
	lt = t[2 * n - 1]
	print((m + lp * lt) / (lp - 1))


n = int(input())
m = int(input())
a = input().split()
b = input().split()
for i in range(n):
	a[i] = int(a[i])
	b[i] = int(b[i])
ls = [b[0]]
for i in range(n):
	if i == n - 1:
		ls.append(a[n - i - 1])
	else:
		ls.append(a[n - i - 1])
		ls.append(b[n - i - 1])
if 1 in ls:
	print(-1)
else:
	fuel = 0
	mass = m
	for i in range(2 * n):
		fuel += mass / (ls[i] - 1)
		mass += mass / (ls[i] - 1)
	print(fuel)


n = int(input())
m = int(input())
lift = list(map(int, input().split()))
land = list(map(int, input().split()))
fuellist = [None] * (2 * n)
for i in range(n):
	fuellist[2 * i] = lift[i]
	if i != n - 1:
		fuellist[2 * i + 1] = land[i + 1]
	else:
		fuellist[2 * i + 1] = land[0]
coe = fuellist[::-1]

def weight(W, A):
	return W * (A / (A - 1))
we = m
if min(lift) <= 1 or min(land) <= 1:
	print(-1)
else:
	for i in range(2 * n):
		we = weight(we, coe[i])
	print(we - m)


def solve():
	n = int(input())
	a = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if 1 in A or 1 in B:
		print(-1)
		return
	z = (A[0], A[-1], B[0], B[-1])
	x = 1
	for e in A[1:-1]:
		x *= e / (e - 1)
	y = 1
	for e in B[1:-1]:
		y *= e / (e - 1)
	p = 1
	for e in z:
		p *= e / (e - 1)
	print(a * (p * x * y - 1))
solve()


import math
import itertools
getInputList = lambda : list(input().split())
getInputIntList = lambda : list(map(int, input().split()))
n = int(input())
m = int(input())
a = getInputIntList()
b = getInputIntList()
w = a + b
left = 0
right = 10 ** 9 + 2
best = -1
while left <= right:
	md = (left + right) // 2
	iw = md + m
	for i in w:
		iw -= iw / i
	if iw >= m:
		best = md
		right = md - 1
	else:
		left = md + 1
left = 0
right = 10 ** 6
ans = best
while left <= right:
	md = (left + right) // 2
	iw = md / 10 ** 6 + m + best - 1
	for i in w:
		iw -= iw / i
	if iw >= m:
		ans = md / 10 ** 6 + best - 1
		right = md - 1
	else:
		left = md + 1
print(min(best, ans))


from itertools import chain
n = int(input())
m = int(input())
aj = list(map(int, input().split()))
bj = list(map(int, input().split()))
res = 0
if 1 not in chain(aj, bj):
	i = 0
	for num in range(len(aj) * 2):
		if num % 2 == 0:
			i -= 1
			x = (m + res) / (bj[i] - 1)
			res += x
		else:
			x = (m + res) / (aj[i] - 1)
			res += x
	print(res)
else:
	print('-1')


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = m
if b[0] - 1 == 0:
	print(-1)
else:
	m = m + m / (b[0] - 1)
	counter = False
	for i in range(n - 1, 0, -1):
		if a[i] - 1 == 0 or b[i] - 1 == 0:
			counter = True
		else:
			m = m + m / (a[i] - 1)
			m = m + m / (b[i] - 1)
	if counter == True or a[0] - 1 == 0:
		print(-1)
	else:
		m = m + m / (a[0] - 1)
		print(m - ans)


n = int(input())
m = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in reversed(range(n)):
	try:
		num = (i + 1) % n
		fuel = m / (b[num] - 1)
		m += fuel
		ans += fuel
		fuel = m / (a[i] - 1)
		m += fuel
		ans += fuel
	except:
		ans = -1
		break
print(ans)


n = int(input())
w = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
t = 1
z = 1
for i in range(n):
	t = t * (a[i] - 1) * (b[i] - 1)
	z = z * a[i] * b[i]
if t == 0 or z == 0:
	ans = -1
else:
	ans = w * (z / t - 1)
print(ans)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = m
for x in a:
	if x <= 1:
		ans = -1
for x in b:
	if x <= 1:
		ans = -1
if ans == -1:
	print(-1)
	exit()
ans += ans / (a[0] - 1)
for i in range(n - 1, 0, -1):
	ans += ans / (b[i] - 1)
	ans += ans / (a[i] - 1)
ans += ans / (b[0] - 1)
print(ans - m)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if 1 in a or 1 in b:
	print(-1)
else:
	temp = m * (b[0] / (b[0] - 1))
	for i in range(n - 1, 0, -1):
		temp = temp * (a[i] / (a[i] - 1))
		temp = temp * (b[i] / (b[i] - 1))
	temp = temp * (a[0] / (a[0] - 1))
	print(temp - m)


n = int(input())
rm = int(input())
t = [int(i) for i in input().split(' ')]
l = [int(i) for i in input().split(' ')]
if 1 in t or 1 in l:
	print(-1)
else:
	ans = rm
	ans += ans / (t[0] - 1)
	for i in range(n - 1, 0, -1):
		ans += ans / (l[i] - 1)
		ans += ans / (t[i] - 1)
	ans += ans / (l[0] - 1)
	ans -= rm
	print(ans)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = 0
l = 1
for t in range(2 * n):
	if t % 2 == 1:
		if not a[t // 2] - 1:
			l = 0
			break
		x = (x * a[t // 2] + m) / (a[t // 2] - 1)
	else:
		if not b[t // 2] - 1:
			l = 0
			break
		x = (x * b[t // 2] + m) / (b[t // 2] - 1)
if l:
	print(x)
else:
	print(-1)


n = int(input())
r = rr = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
try:
	for i in range(0, -n, -1):
		r += r / (a[i] - 1)
		r += r / (b[i - 1] - 1)
	print(r - rr)
except ZeroDivisionError:
	print(-1)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = 0
r = 1000000001

def can(w):
	z = w + m
	x = w - z / a[0]
	if x < 0:
		return 0
	for i in range(1, n):
		x = x - (x + m) / b[i]
		if x < 0:
			return 0
		x = x - (x + m) / a[i]
		if x < 0:
			return 0
	x = x - (x + m) / b[0]
	if x < 0:
		return 0
	return 1
while r - l >= 1e-06:
	w = (r + l) / 2
	if can(w):
		r = w
	else:
		l = w
if r == 1000000001:
	print(-1)
else:
	print(round(r, 6))


n = int(input())
m = int(input())
aj = list(map(int, input().split()))
bj = list(map(int, input().split()))
res = 0
if not 1 in aj and (not 1 in bj):
	i = 0
	for num in range(len(aj) * 2):
		if num % 2 == 0:
			i -= 1
			x = (m + res) / (bj[i] - 1)
			res += x
		else:
			x = (m + res) / (aj[i] - 1)
			res += x
	print(res)
else:
	print('-1')


def f(a, b, n, m, t):
	for i in range(n):
		t -= (m + t) / a[i]
		if t < 0:
			return False
		t -= (m + t) / b[i]
		if t < 0:
			return False
	return True
n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = 0
r = 1000000001
for i in range(1000):
	t = (l + r) / 2
	if f(a, b, n, m, t):
		r = t + 0
	else:
		l = t + 0
if r == 1000000001:
	print(-1)
else:
	print(r)


def main():
	n = int(input())
	start_m = m = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	try:
		mt = m / (b[0] - 1)
	except ZeroDivisionError:
		print(-1)
		return
	m += mt
	for i in range(len(a)):
		try:
			mt = m / (a[len(a) - i - 1] - 1)
		except ZeroDivisionError:
			print(-1)
			return
		m += mt
		if i == len(a) - 1:
			continue
		try:
			mt = m / (b[len(b) - i - 1] - 1)
		except ZeroDivisionError:
			print(-1)
			return
		m += mt
	print(m - start_m)
main()


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(S, D) = (1, 1)
for i in a:
	S *= i
	D *= i - 1
for i in b:
	S *= i
	D *= i - 1
if D == 0:
	print(-1)
else:
	print((S - D) * m / D)


n = int(input())
m = int(input())
a = [int(e) for e in input().split()]
b = [int(e) for e in input().split()]
if 1 in a or 1 in b:
	print(-1)
else:
	m0 = m
	for i in range(n - 1, -1, -1):
		k = b[(i + 1) % n]
		m *= k / (k - 1)
		k = a[i]
		m *= k / (k - 1)
	print('{:.10f}'.format(m - m0))


def solve(n):
	n = n - n / s[0]
	for i in range(1, len(s)):
		n = n - n / s1[i]
		n = n - n / s[i]
		if n < m:
			return False
	n = n - n / s1[0]
	return n >= m
n = int(input())
m = int(input())
s = list((int(x) for x in input().split()))
s1 = list((int(x) for x in input().split()))
low = 1
high = 10 ** 9 + 5
while high - low > 1e-06:
	mid = (high + low) / 2
	if solve(mid + m):
		high = mid
	else:
		low = mid
if solve(low + m):
	print(low)
elif solve(high + m):
	print(high)
else:
	print(-1)


n = int(input())
w = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
if min(l1 + l2) <= 1:
	print(-1)
else:
	out = w
	for i in l1 + l2:
		out *= i / (i - 1)
	print(out - w)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b = b[1:] + b[:1]
ans = m
for i in reversed(range(n)):
	try:
		ans += ans / (b[i] - 1)
		ans += ans / (a[i] - 1)
	except ZeroDivisionError:
		print(-1)
		exit()
ans -= m
print(ans if ans > 0 else -1)


n = int(input())
masa_rakiety = int(input())
start = list(map(int, input().split()))
ladowanie = list(map(int, input().split()))
masa = masa_rakiety
if min(start + ladowanie) <= 1:
	print(-1)
	exit()
for i in start + ladowanie:
	masa *= i / (i - 1)
print(masa - masa_rakiety)


n = int(input())
m = int(input())
ara = [-1] + list(map(int, input().split()))
arb = [-1] + list(map(int, input().split()))
planet = 1
prev = -1
w = m
while prev != 1:
	if planet == 1:
		prev = n
	else:
		prev = planet - 1
	if arb[planet] == 1 or ara[planet] == 1:
		w = 0
		m = 1
		break
	t = w / (arb[planet] - 1)
	w += t
	t = w / (ara[planet] - 1)
	w += t
	planet = prev
print(w - m)


n = int(input())
m = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
if 1 in a or 1 in b:
	print(-1)
else:
	s = m
	s += s / (b[0] - 1)
	for i in range(n - 1, 0, -1):
		s += s / (a[i] - 1)
		s += s / (b[i] - 1)
	s += s / (a[0] - 1)
	print(round(s - m, 6))


n = int(input())
m = int(input())
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
x = m
index = []
for i in range(n):
	index.append(a[n - 1 - i])
	index.append(b[n - 1 - i])
index.insert(0, b[0])
for i in range(2 * n):
	if index[i] <= 1:
		print(-1)
		break
	else:
		x += x / (index[i] - 1)
else:
	print(x - m)


mod = 10 ** 9 + 7
import math
for _ in range(1):
	n = int(input())
	load = int(input())
	zp = load
	load += 1e-15
	pk = list(map(int, input().split()))
	pk1 = list(map(int, input().split()))
	d = []
	for i in range(n):
		d.append(pk[i])
		d.append(pk1[(i + 1) % n])
	flag = 0
	for i in range(2 * n - 1, -1, -1):
		if d[i] == 1:
			flag = 1
			break
		load += load / (d[i] - 1)
	if flag == 1:
		print(-1)
	else:
		print(load - zp)


import math as ma
from sys import exit
from decimal import Decimal as dec

def li():
	return list(map(int, input().split()))

def modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
n = nu()
m = nu()
x = 1
a = li()
b = li()
for i in range(n):
	x *= 1 - 1 / a[i]
for i in range(n):
	x *= 1 - 1 / b[i]
if x <= 0:
	print(-1)
else:
	x = m / x - m
	print(x)


import sys
n = int(input())
m = int(input())
a = list(map(int, input().split()))
for i in range(n):
	if a[i] <= 1:
		print(-1)
		exit()
b = list(map(int, input().split()))
for i in range(n):
	if b[i] <= 1:
		print(-1)
		exit()
s = m
s += s / (a[0] - 1)
for i in range(n - 1, 0, -1):
	s *= b[i]
	s /= b[i] - 1
	s *= a[i]
	s /= a[i] - 1
s += s / (b[0] - 1)
print(s - m)


n = int(input())
m = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
numerator = m
denominator = 1
for i in range(n):
	numerator *= a[i]
	numerator *= b[i]
	denominator *= a[i] - 1
	denominator *= b[i] - 1
if denominator == 0:
	print(-1)
else:
	ans = numerator / denominator - m
	print(ans)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def f(x):
	summ = x + m
	for i in range(n):
		summ -= summ / a[i % n]
		summ -= summ / b[(i + 1) % n]
		if summ < m:
			return False
	if summ < m:
		return False
	return True
left = 0
right = 10 ** 9 + 1
while right - left >= 10 ** (-6):
	mid = (left + right) / 2
	if f(mid):
		right = mid
	else:
		left = mid
if right > 10 ** 9 + 10 ** (-5):
	print(-1)
else:
	print(right)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if 1 in a or 1 in b:
	print(-1)
	exit()
list_ = [a[0]]
for i in range(1, n):
	list_.append(b[i])
	list_.append(a[i])
list_.append(b[0])
need = list_[::-1]
mas = m
for el in need:
	mas += mas / (el - 1)
print(mas - m)


n = int(input())
m = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
if arr2[0] > 1 and arr1[0] > 1:
	w = m + m / (arr2[0] - 1)
	flag = 0
	for i in range(n - 1, 0, -1):
		if arr1[i] <= 1 or arr2[i] <= 1:
			print(-1)
			flag = 1
			break
		w += w / (arr1[i] - 1)
		w += w / (arr2[i] - 1)
	if flag == 0:
		w += w / (arr1[0] - 1)
		print(w - m)
else:
	print(-1)


from sys import stdin
from math import *

def evaluate(currentFuel, ab, m):
	for i in range(len(ab)):
		currentFuel -= (currentFuel + m) / ab[i]
		if currentFuel <= -1e-07:
			return False
	return True
line = stdin.readline().rstrip().split()
n = int(line[0])
line = stdin.readline().rstrip().split()
m = int(line[0])
aFuel = list(map(int, stdin.readline().rstrip().split()))
bFuel = list(map(int, stdin.readline().rstrip().split()))
ab = []
for i in range(n - 1):
	ab.append(aFuel[i])
	ab.append(bFuel[i + 1])
ab.append(aFuel[n - 1])
ab.append(bFuel[0])
minFuel = 0
maxFuel = 1000000000
currentFuel = (minFuel + maxFuel) / 2
while maxFuel - minFuel >= 5e-07:
	if evaluate(currentFuel, ab, m):
		maxFuel = currentFuel
	else:
		minFuel = currentFuel
	currentFuel = (minFuel + maxFuel) / 2
if evaluate(1000000000, ab, m):
	print(currentFuel)
else:
	print(-1)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
start = m
if b[0] - 1 <= 0:
	print(-1)
else:
	m += m / (b[0] - 1)
	flag = True
	for i in range(n - 1, 0, -1):
		if a[i] - 1 <= 0:
			flag = False
			print(-1)
			break
		else:
			m += m / (a[i] - 1)
		if b[i] - 1 <= 0:
			flag = False
			print(-1)
			break
		else:
			m += m / (b[i] - 1)
	if flag:
		if a[0] - 1 <= 0:
			print(-1)
		else:
			m += m / (a[0] - 1)
			print(m - start)


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
y = int(input())
z = y
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if 1 in a or 1 in b:
	print(-1)
	exit(0)
for i in range(n):
	x = y / (a[i] - 1)
	y += x
for i in range(n):
	x = y / (b[i] - 1)
	y += x
print(y - z)


n = int(input())
m = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
z = (a[0] - 1) / a[0]
l = 0
for i in range(1, n):
	z = z * (b[i] - 1) / b[i]
	z = z * (a[i] - 1) / a[i]
z = z * (b[0] - 1) / b[0]
try:
	print('{0:.10f}'.format(m / z - m))
except:
	print(-1)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def f(x, a):
	if a == 0 or a == 1:
		print(-1)
		import sys
		sys.exit(0)
	return x * (1 / a) / (1 - 1 / a)
cur_wt = m
for bi in b:
	cur_wt = cur_wt + f(cur_wt, bi)
for ai in reversed(a):
	cur_wt = cur_wt + f(cur_wt, ai)
print('%f' % (cur_wt - m))


def can(n):
	n = n - n / s[0]
	for i in range(1, len(s)):
		n = n - n / s1[i]
		n = n - n / s[i]
		if n < w:
			return False
	n = n - n / s1[0]
	return n >= w
n = int(input())
w = int(input())
s = list(map(int, input().split()))
s1 = list(map(int, input().split()))
low = 1
high = 10 ** 9 + 2
while high - low > 1e-06:
	mid = (high + low) / 2
	if can(mid + w):
		high = mid
	else:
		low = mid
if can(low + w):
	print(low)
elif can(high + w):
	print(high)
else:
	print(-1)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if 1 in a or 1 in b:
	print(-1)
	exit(0)
res = 0.0
y = m / (b[0] - 1.0)
x = (m + y) / (a[n - 1] - 1.0)
res += x + y
for i in range(n - 1, 0, -1):
	y = (m + res) / (b[i] - 1.0)
	x = (m + y + res) / (a[i - 1] - 1.0)
	res += x + y
print(res)


eps = 7.5e-07

def check(x):
	temp_m = m + x
	for i in range(n):
		delta = temp_m / a[i]
		x -= delta
		temp_m -= delta
		if x < 0:
			return False
		delta = temp_m / b[(i + 1) % n]
		x -= delta
		temp_m -= delta
		if x < 0:
			return False
	return True
n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = 0
r = 1000000001
while r - l >= eps:
	mid = (r + l) / 2
	if check(mid):
		r = mid
	else:
		l = mid
if r == 1000000001:
	print(-1)
else:
	print(r)


import functools
import time
from collections import Counter

def timer(func):

	@functools.wraps(func)
	def wrapper(*args, **kwargs):
		stime = time.perf_counter()
		res = func(*args, **kwargs)
		elapsed = time.perf_counter() - stime
		print(f'{func.__name__} in {elapsed:.4f} secs')
		return res
	return wrapper

class solver:

	def __init__(self):
		pass

	def __call__(self):
		n = int(input())
		m = int(input())
		a = list(map(int, input().strip().split()))
		b = list(map(int, input().strip().split()))

		def check(r):
			for i in range(n):
				r -= (m + r) / a[i]
				r -= (m + r) / b[(i + 1) % n]
			return r >= 0
		(lo, hi) = (0, 1000000000.0)
		for _ in range(100):
			md = (lo + hi) / 2
			if check(md):
				hi = md
			else:
				lo = md
		if not check(lo + 1e-06):
			print('-1')
		else:
			print(f'{lo:.9f}')
solver()()


n = int(input())
m = int(input())
fly = list(map(int, list(input().split())))
land = list(map(int, list(input().split())))
temp_list = []
try:
	temp_list.append(land[0])
	for i in range(n - 1, 0, -1):
		temp_list.append(fly[i])
		temp_list.append(land[i])
	temp_list.append(fly[0])
	res = m
	for i in temp_list:
		res = res + res / (i - 1)
	print(str(res - m))
except:
	print('-1')


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(b[0])
ans = 0
w = m
p = 0
for i in range(2 * n):
	if i % 2 == 0:
		if a[p] - 1 <= 0:
			ans = -1
			break
		x = w / (a[p] - 1)
		ans += x
		w += x
		p += 1
	else:
		if b[p] - 1 <= 0:
			ans = -1
			break
		x = w / (b[p] - 1)
		ans += x
		w += x
print(ans)


n = int(input())
m = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
k = 1
for i in A:
	k *= 1 - 1 / i
for i in B:
	k *= 1 - 1 / i
if k == 0:
	ans = -1
else:
	ans = (m - k * m) / k
print(ans)


p = int(input())
w = float(input())
a = input().split()
b = input().split()
w_a = w
takky = [b[0]]
for i in range(0, len(a)):
	takky.append(a[len(a) - i - 1])
	if len(a) != i + 1:
		takky.append(b[len(a) - i - 1])
for w1 in takky:
	if int(w1) - 1 == 0:
		ans = -1
		break
	w2 = float(w_a / (int(w1) - 1))
	w_a = w_a + w2
	ans = w_a
	if w_a - w == 1000000000:
		ans = -1
		break
if ans == -1:
	print(-1)
else:
	print(ans - w)


import sys
n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def get_landing(w, stage):
	return w / (b[stage] - 1)

def get_takeoff(w, stage):
	return w / (a[stage] - 1)
try:
	total_fuel = 0
	land_earth = get_landing(m, 0)
	total_fuel += land_earth
	m += land_earth
	for i in range(n - 1, 0, -1):
		take = get_takeoff(m, i)
		m += take
		total_fuel += take
		land = get_landing(m, i)
		total_fuel += land
		m += land
	total_fuel += get_takeoff(m, 0)
	print(total_fuel)
except:
	print(-1)


n = int(input())
m = int(input())
coeffs = []
coeffs.append(list(map(int, input().split())))
coeffs.append(list(map(int, input().split())))
coeffs[1].append(coeffs[1][0])
m_orig = m

def getFuel():
	global m
	for i in range(n):
		for parity in range(2):
			coeff = coeffs[1 - parity][-1 - i]
			if coeff == 1:
				return -1
			else:
				f = m / (coeff - 1)
				m = m + f
	return m - m_orig
print(getFuel())


input()
ship = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
forward = [item for tup in zip(b, a) for item in tup]
revers = [item for tup in zip(a, b) for item in tup][::-1]
trajectory = forward[1:]
trajectory.append(forward[0])
fuel = 0
for co in reversed(trajectory):
	if co == 1:
		fuel = -1
		break
	fuel += (ship + fuel) / (co - 1)
print(fuel)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = 1
j = 0
f = 0
while j < n:
	if a[j] == 1 or b[j] == 1:
		f = -1
		break
	r *= (1 - 1 / a[j]) * (1 - 1 / b[j])
	j += 1
if f == -1:
	print(-1)
else:
	x = m * (1 / r - 1)
	if x > 0:
		print(x)
	else:
		print(-1)


from bisect import bisect
from collections import defaultdict
from math import gcd, sqrt, ceil, inf
from collections import Counter
import sys
sys.setrecursionlimit(1000000)
from bisect import bisect
from collections import defaultdict
from math import gcd, sqrt, ceil, inf
from collections import Counter
import sys
sys.setrecursionlimit(10 ** 9)

def check(w, f):
	for i in range(n):
		if f > 0:
			f = f - (w + f) / l1[i]
			if f > 0:
				f = f - (w + f) / l2[(i + 1) % n]
			else:
				return False
		else:
			return False
	if f < 0:
		return False
	return True
n = int(input())
w = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

def solve():
	l = 0
	r = 10 ** 9
	while r >= l:
		f = l + (r - l) / 2
		if check(w, f):
			r = f - 1 / 10 ** 6
		else:
			l = f + 1 / 10 ** 6
	if check(w, l - 1 / 10 ** 6):
		return l - 1 / 10 ** 6
	elif check(w, l):
		return l
	elif check(w, l + 1 / 10 ** 6):
		return l + 1 / 10 ** 6
	return -1
print(solve())


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(l, r) = (0, 10 ** 9 + 1)
while l + 10 ** (-6) < r:
	mid = (l + r) / 2
	last = mid
	good = True
	for i in range(n):
		last -= (last + m) / a[i]
		if last < 0:
			good = False
			break
		last -= (last + m) / b[(i + 1) % n]
		if last < 0:
			good = False
			break
	if good:
		r = mid
	else:
		l = mid
if l - 10 ** 9 > 10 ** (-6):
	print(-1)
	exit()
print('%.6f' % l)


n = int(input())
m = int(input())
a = [int(c) for c in input().split(' ')]
b = [int(c) for c in input().split(' ')]
c = 1
for i in a:
	c = c * (1 - 1 / i)
for i in b:
	c = c * (1 - 1 / i)
if c > 0:
	print(m * (1 / c - 1))
else:
	print(-1)


from sys import stdin
n = int(stdin.readline())
m = int(stdin.readline())
a = [int(x) for x in stdin.readline().split()]
b = [int(x) for x in stdin.readline().split()]
w = m
for i in range(n):
	ax = a[-i - 1]
	bx = b[-i]
	if ax == 1 or bx == 1:
		print(-1)
		exit()
	w += w / (bx - 1.0)
	w += w / (ax - 1.0)
print(w - m)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if 1 in a or 1 in b:
	print(-1)
	exit(0)

def f(vol):
	for i in range(n - 1):
		vol -= (vol + m) / a[i]
		if vol < 0:
			return 0
		vol -= (vol + m) / b[i + 1]
		if vol < 0:
			return 0
	vol -= (vol + m) / a[n - 1]
	if vol < 0:
		return 0
	vol -= (vol + m) / b[0]
	if vol < 0:
		return 0
	return 1
(l, r) = (0, 1000000000.0)
while r - l > 1e-06:
	mid = (l + r) / 2
	if f(mid):
		r = mid
	else:
		l = mid
print(mid)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = 0
r = 10 ** 9 + 1
while (r - l) * 10 ** 6 >= 1:
	try1 = (l + r) / 2
	fuel = try1
	flag = 0
	for i in range(n):
		if fuel + m > a[i] * fuel:
			flag = 1
			break
		fuel -= (fuel + m) / a[i]
		if fuel + m > b[(i + 1) % n] * fuel:
			flag = 1
			break
		fuel -= (fuel + m) / b[(i + 1) % n]
	if flag:
		l = try1
	else:
		r = try1
if l > 10 ** 9:
	print(-1)
else:
	print(l)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if 1 in a or 1 in b:
	print(-1)
	exit(0)

def fuel(m, k):
	return m + m / (k - 1)
w = fuel(m, b[0])
for i in range(n - 1, 0, -1):
	w = fuel(w, a[i])
	w = fuel(w, b[i])
w = fuel(w, a[0])
print(w - m)


n = int(input())
p = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
if 1 in a or 1 in b:
	print(-1)
else:
	transitions = (n - 1) * 2
	coming = [0] * transitions
	coming[0] = b[0]
	coming[-1] = a[-1]
	for i in range(1, n - 1):
		coming[2 * i - 1] = a[i]
		coming[2 * i] = b[i]
	going = [0] * transitions
	going[0] = b[-1]
	going[-1] = a[0]
	for i in range(1, n - 1):
		going[i * 2] = b[i]
		going[i * 2 - 1] = a[i]
	ans = p
	ans += ans / (b[0] - 1)
	ans += ans / (a[-1] - 1)
	for i in going:
		ans += ans / (i - 1)
	print(ans - p)


n = int(input())
m = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

def fuelLanding(weight, planet):
	if b[planet] == 1:
		return -1
	return weight / (b[planet] - 1)

def fuelTakeoff(weight, planet):
	if a[planet] == 1:
		return -1
	return weight / (a[planet] - 1)
res = 0
wrong = 0
for i in reversed(range(n)):
	if fuelTakeoff(m, i) == -1:
		wrong = 1
	res += fuelTakeoff(m, i)
	m += fuelTakeoff(m, i)
	if fuelLanding(m, i) == -1:
		wrong = 1
	res += fuelLanding(m, i)
	m += fuelLanding(m, i)
if wrong == 1:
	print(-1)
else:
	print(res)