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 \to 2 \to \ldots n \to 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 $\to$ take-off from the $1$-st planet $\to$ landing to the $2$-nd planet $\to$ $2$-nd planet $\to$ take-off from the $2$-nd planet $\to$ $\ldots$ $\to$ landing to the $n$-th planet $\to$ the $n$-th planet $\to$ take-off from the $n$-th planet $\to$ landing to the $1$-st planet $\to$ 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 \cdot 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 \le n \le 1000$) — number of planets.

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

The third line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 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, \ldots, b_n$ ($1 \le b_i \le 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|)}} \le 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.

Source: codeforces | Difficulty: MEDIUM
Tags: Sorting

Mathematics


Solutions:
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)


i = input
i()
m = int(i())
v = m
try:
	for a in map(int, (i() + ' ' + i()).split()):
		v *= a / (a - 1)
except:
	v = m - 1
print(v - 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())
toff = list(map(int, input().split()))
land = list(map(int, input().split()))
con = toff + land
coff = 1
for i in range(len(con)):
	coff *= 1 - 1 / con[i]
try:
	print(m * (1 / coff - 1))
except:
	print(-1)


from functools import reduce
n = int(input())
m = int(input())
a = input().split()
a = [int(x) for x in a]
b = input().split()
b = [int(x) for x in b]
k = m
y = 1
for i in range(len(a)):
	k = k * a[i] * b[i]
a = [int(x) - 1 for x in a]
b = [int(x) - 1 for x in b]
for i in range(len(a)):
	y = y * a[i] * b[i]
if y == 0:
	print(-1)
else:
	print(k / y - m)


import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None
		self.BUFSIZE = 8192

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def get_int():
	return int(input())

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

def get_int_grid(n):
	return [get_ints() for _ in range(n)]

def get_str():
	return input().split(' ')

def yes_no(b):
	if b:
		return 'YES'
	else:
		return 'NO'

def prefix_sums(a):
	p = [0]
	for x in a:
		p.append(p[-1] + x)
	return p

def binary_search(good, left, right, delta=1, right_true=False):
	limits = [left, right]
	while limits[1] - limits[0] > delta:
		if delta == 1:
			mid = sum(limits) // 2
		else:
			mid = sum(limits) / 2
		if good(mid):
			limits[int(right_true)] = mid
		else:
			limits[int(~right_true)] = mid
	if good(limits[int(right_true)]):
		return limits[int(right_true)]
	else:
		return False

def solve_a():
	n = get_int()
	m = get_int()
	a = get_ints()
	b = get_ints()

	def good(k):
		for i in range(n):
			k -= (m + k) / a[i]
			k -= (m + k) / b[i]
		return k >= 0
	ans = binary_search(good, 0, 10 ** 9 + 1, delta=10 ** (-6), right_true=True)
	if not ans:
		return -1
	else:
		return ans
print(solve_a())


(n, m, a, b) = (input() for i in range(4))
(n, m) = (int(n), int(m))
cost = list(zip((int(i) for i in a.split()), (int(i) for i in b.split())))
fuel = 0
total = m
try:
	c = total / (cost[0][1] - 1)
	fuel += c
	total += c
	for i in cost[:0:-1]:
		c = total / (i[0] - 1)
		fuel += c
		total += c
		c = total / (i[1] - 1)
		fuel += c
		total += c
	fuel += total / (cost[0][0] - 1)
	print(f'{fuel:.10f}')
except ZeroDivisionError:
	print(-1)


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)


x = int(input())
y = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = y
p = y
a = a + b
if 1 in a:
	print(-1)
	exit()
for i in a:
	s += s / (i - 1)
print(s - y)


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())
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)


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 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))


planet = int(input())
mass = int(input())
case = 0
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
for i in range(0, planet):
	if A[i] == 1 or B[i] == 1:
		case = 1
		break
if case == 0:
	temp = mass * 1.0
	temp = temp / (1.0 - 1.0 / (1.0 * B[0]))
	for i in range(planet - 1, 0, -1):
		temp = temp / (1.0 - 1.0 / (A[i] * 1.0))
		temp = temp / (1.0 - 1.0 / (B[i] * 1.0))
	temp = temp / (1.0 - 1.0 / (A[0] * 1.0))
	temp = temp - mass * 1.0
if case == 1:
	print('-1')
else:
	print(temp)


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())
h = m
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if 1 in a or 1 in b:
	print(-1)
else:
	for i in range(n):
		m += m / (a[i] - 1)
		m += m / (b[i] - 1)
	print(m - h)


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


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(n):
	c.append(a[i])
	c.append(b[(i + 1) % n])
c = c[::-1]
s = m
e = 0
for i in range(len(c)):
	if c[i] == 1:
		e = 1
	else:
		s = s + s / (c[i] - 1)
if e == 1:
	print(-1)
else:
	print(s - m)


def main():
	input()
	x = m = float(input())
	try:
		for s in (input(), input()):
			for a in map(float, s.split()):
				x *= a / (a - 1.0)
		print(x - m)
	except ZeroDivisionError:
		print(-1)
main()


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)


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)


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


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)


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)


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())


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = m
f = 0
for i in range(n - 1, -1, -1):
	t = b[(i + 1) % n]
	if t == 1:
		print('-1')
		f = 1
		break
	res += res / (t - 1)
	t = a[i]
	if t == 1:
		print('-1')
		f = 1
		break
	res += res / (t - 1)
res = res - m
if f != 1:
	print(res, end='00000000')
print()


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())
m = float(input())
s = input()
vo = []
vo = s.split()
a = []
for i in range(len(vo)):
	a.append(1.0 * float(vo[i]))
sb = input()
vb = []
vb = sb.split()
b = []
for i in range(len(vb)):
	b.append(1.0 * float(vb[i]))
ans = m
c = b[0] - 1.0
bol = 1
if c > 0.0:
	pc = ans / (b[0] - 1.0)
	ans = ans + pc
else:
	bol = 0
if bol != 0:
	for i in range(n - 1, 0, -1):
		c = a[i] - 1.0
		if c > 0.0:
			pc = ans / (a[i] - 1.0)
			ans = ans + pc
		else:
			bol = 0
		c = b[i] - 1.0
		if c > 0.0:
			pc = ans / (b[i] - 1.0)
			ans = ans + pc
		else:
			bol = 0
		if bol == 0:
			break
	if bol != 0:
		c = a[0] - 1.0
		if c > 0.0:
			pc = ans / (a[0] - 1.0)
			ans = ans + pc
			ans = ans - m
			print('%.10f' % ans)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(-1)


import io, os, sys
try:
	fin = open('in')
	input = fin.readline
except:
	input = sys.stdin.readline
n = int(input())
s = int(input())
S = s
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if any((t <= 1 for t in a + b)):
	print(-1)
else:
	s += s / (a[0] - 1)
	for i in range(n - 1, 0, -1):
		s += s / (b[i] - 1)
		s += s / (a[i] - 1)
	s += s / (b[0] - 1)
	print(s - S)


from math import ceil

def check(a, fuel, w):
	tw = fuel + w
	state = 0
	tw -= tw / a[0][0]
	if tw < w:
		return False
	for i in range(1, len(a)):
		x = tw / a[i][0]
		tw -= x
		x = tw / a[i][1]
		tw -= x
		if tw < w:
			return False
	tw -= tw / a[0][1]
	if tw < w:
		return False
	return True

def f(a, w):
	lo = 1
	hi = 10 ** 9 + 3
	res = float('inf')
	cnt = 0
	while lo <= hi and cnt < 100:
		cnt += 1
		m = (lo + hi) / 2
		if check(a, m, w):
			hi = m
			res = min(res, m)
		else:
			lo = m
	if res == float('inf') or res == 10 ** 9:
		return -1
	return res
n = int(input())
w = int(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
a = list(zip(a, b))
print(f(a, w))


n = int(input())
m = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
tmp = 1.0
for i in range(0, n):
	tmp *= (a[i] - 1) * (b[i] - 1)
	tmp /= a[i]
	tmp /= b[i]
if tmp == 0:
	print('-1\n')
	exit(0)
fuel = m * (1 - tmp) / tmp
if fuel >= 1e-07:
	print(fuel)
else:
	print('-1\n')


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())
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')


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)


p = 1e-06

def check(a, b, mass, val):
	m = mass + val
	m -= m / a[0]
	for i in range(1, len(a)):
		m -= m / b[i]
		m -= m / a[i]
	m -= m / b[0]
	return m >= mass

def search(a, b, mass, low, high):
	solved = False
	while high - low >= p:
		mid = low + (high - low) / 2
		if check(a, b, mass, mid):
			solved = True
			high = mid
		else:
			low = mid
	if solved:
		return high
	else:
		return -1
n = int(input())
mass = int(input())
a = [int(x) for x in input().strip().split()]
b = [int(x) for x in input().strip().split()]
print('{:0.10f}'.format(search(a, b, mass, 0, 1000000000 + p + 1)))


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)


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)


from sys import stdin
EPS = 1e-06
n = int(stdin.readline())
m = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
b.append(b[0])

def check(f):
	fuel_left = f
	total_weight = float(m + fuel_left)
	for i in range(n):
		cost = total_weight / a[i]
		fuel_left = fuel_left - cost
		total_weight = total_weight - cost
		cost = total_weight / b[i + 1]
		fuel_left = fuel_left - cost
		total_weight = total_weight - cost
		if fuel_left < 0:
			return False
	return True

def binary_search(left, right):
	mid = (left + right) / 2
	if abs(left - right) < EPS:
		return mid
	if check(mid):
		return binary_search(left, mid)
	else:
		return binary_search(mid, right)
res = binary_search(0, 1000000000.0 + 1)
if res - 1000000000.0 > EPS:
	print(-1)
else:
	print('%.10f' % res)


n_planet = int(input())
m_rocket = int(input())
a_i = [int(x) for x in input().split(' ')]
b_i = [int(x) for x in input().split(' ')]

def main(n, m, a, b):
	fuel = -1
	try:
		(a + b).index(1)
	except ValueError:
		fuel = m / (b[0] - 1)
		l = list(range(1, n))
		l.reverse()
		for i in l:
			fuel = (m + fuel * a[i]) / (a[i] - 1)
			fuel = (m + fuel * b[i]) / (b[i] - 1)
		fuel = (m + fuel * a[0]) / (a[0] - 1)
	return fuel
print(main(n_planet, m_rocket, a_i, b_i))


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)


import math

def issuff(n, m, a, b, f):
	for i in range(n):
		if f > 0:
			burn = (f + m) / a[i]
			f = round(f - burn, 6)
			burn = (f + m) / b[(i + 1) % n]
			f = round(f - burn, 6)
		if f < 0:
			return False
	return True

def answer(n, m, a, b):
	l = 0.1
	r = 1000000006
	ans = -1
	while r >= l:
		mid = round((r + l) / 2, 6)
		if issuff(n, m, a, b, mid):
			ans = mid
			r = mid - 1e-06
		else:
			l = mid + 1e-06
	return ans
n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(answer(n, m, a, b))


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())
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)


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)


from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n,) = gil()
(w,) = gil()
(lift, land) = (gil(), gil())

def isPos(fw):
	cw = w + fw
	delta = cw / lift[0]
	fw -= delta
	cw -= delta
	if fw <= 0:
		return False
	for i in range(1, n):
		delta = cw / land[i]
		fw -= delta
		cw -= delta
		if fw <= 0:
			return False
		delta = cw / lift[i]
		fw -= delta
		cw -= delta
		if fw <= 0:
			return False
	if fw <= 0:
		return False
	delta = cw / land[0]
	fw -= delta
	return False if fw < 0 else True
ans = -1
(l, r) = (float(0), 2 * float(1000000000.0))
d = float(1e-06)
while l <= r:
	mid = (l + r) / 2
	if isPos(mid):
		ans = mid
		r = mid - d
	else:
		l = mid + d
print(ans)


from decimal import Decimal, getcontext
getcontext().prec = 100
n = int(input())
m = Decimal(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a.count(1) or b.count(1):
	print(-1)
	exit(0)
a = list(map(Decimal, a))
b = list(map(Decimal, b))
ans = Decimal(1)
for i in range(n):
	ans = ans * a[i] / (a[i] - 1)
	ans = ans * b[i] / (b[i] - 1)
ans -= 1
print('%.20f' % (Decimal(m) * ans))


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)


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))))


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())
mm = 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 - mm)


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))


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


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

def c(x):
	x -= (m + x) / a[0]
	for i in range(1, n):
		x -= (m + x) / b[i]
		if x < 0:
			return False
		x -= (m + x) / a[i]
		if x < 0:
			return False
	x -= (m + x) / b[0]
	return x >= 0
(l, r) = (0, 10 ** 9 + 1)
x = 0
for i in range(100):
	x = (l + r) / 2
	if c(x):
		r = x
		o = x
	else:
		l = x
if r == 10 ** 9 + 1:
	print(-1)
else:
	print(r)


n = int(input())
m = int(input())
t = 0
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if b[0] > 1:
	s = m + m / (b[0] - 1)
	for i in range(n - 1, -1, -1):
		if a[i] == 1 or b[i] == 1:
			t = 1
			break
		s += s / (a[i] - 1)
		if i > 0:
			s += s / (b[i] - 1)
	if t:
		print('-1', end='')
	else:
		print(s - m, end='')
else:
	print('-1', end='')


def good_combination(m, a, b, f):
	weight = m + f
	for i in range(len(a)):
		burnt_takeoff = weight / a[i]
		weight -= burnt_takeoff
		burnt_landing = weight / b[i]
		weight -= burnt_landing
		if weight < m:
			return False
	return True

def solve(m, a, b):
	if not good_combination(m, a, b, 1000000001):
		return -1
	l = 1
	r = 1000000000
	while r - l > 10 ** (-6):
		mid = (l + r) / 2
		if good_combination(m, a, b, mid):
			r = mid
		else:
			l = mid
	return l if good_combination(m, a, b, l) else r
input()
m = int(input().strip())
a = [int(x) for x in input().strip().split()]
b = [int(x) for x in input().strip().split()]
print(solve(m, a, b))


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()


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)


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)


import collections, atexit, math, sys
from functools import cmp_to_key
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
import bisect
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, **kwargs, file=sys.stderr)
	dprint('debug mode')
except ModuleNotFoundError:

	def dprint(*args, **kwargs):
		pass

def memo(func):
	cache = {}

	def wrap(*args):
		if args not in cache:
			cache[args] = func(*args)
		return cache[args]
	return wrap

@memo
def comb(n, k):
	if k == 0:
		return 1
	if n == k:
		return 1
	return comb(n - 1, k - 1) + comb(n - 1, k)
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
(M,) = getIntList()
za = getIntList()
zb = getIntList()
if 1 in za or 1 in zb:
	print(-1)
	sys.exit()

def trywork(fuel):
	for i in range(N):
		now = fuel + M
		cost = now / za[i]
		fuel -= cost
		if fuel < 0:
			return False
		now = fuel + M
		cost = now / zb[(i + 1) % N]
		fuel -= cost
		if fuel < 0:
			return False
	return True
r0 = 0
r1 = 10 ** 9 + 1
while r1 - r0 > 1e-07 and (r1 - r0) * 10000000 > r1:
	m = (r1 + r0) / 2
	f = trywork(m)
	if f:
		r1 = m
	else:
		r0 = m
print(r1)


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)


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())
M = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def check(m):
	for i in range(N):
		w = m + M
		m -= w / A[i]
		if m < 0:
			return False
		w = m + M
		m -= w / B[(i + 1) % N]
		if m < 0:
			return False
	return True
l = 0
r = pow(10, 9) + 1
while l + 1e-07 < r:
	m = (l + r) / 2
	if check(m):
		r = m
	else:
		l = m
if r > pow(10, 9) + 0.1:
	r = -1
print(r)


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

def check(t):
	for i in range(n):
		t -= (t + m) / a[i]
		if t < 0:
			return 0
		t -= (t + m) / b[(i + 1) % n]
		if t < 0:
			return 0
	return 1
(l, r) = (0, 10 ** 10)
if not check(r):
	print(-1)
else:
	for i in range(300):
		mid = (l + r) / 2
		if check(mid):
			r = mid
		else:
			l = mid
	print(l)


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')


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 = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = n - 1
mm = m
c = 1
while x >= 0:
	y = (x + 1) % n
	try:
		m += m / (b[y] - 1)
		m += m / (a[x] - 1)
	except:
		print(-1)
		c = 0
		break
	x -= 1
if c != 0:
	print(m - mm)


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)


N = int(input())
M = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
for i in range(len(a)):
	if a[i] == 1 or b[i] == 1:
		print(-1)
		exit()

def galima(fuel):
	fuel -= (M + fuel) / a[0]
	for i in range(1, len(a)):
		fuel -= (M + fuel) / a[i]
		fuel -= (M + fuel) / b[i]
	fuel -= (M + fuel) / b[0]
	if fuel >= 0:
		return True
	else:
		return False
low = 0.0
high = 1000000000.0
for _ in range(300):
	mid = (low + high) / 2
	if galima(mid):
		high = mid
	else:
		low = mid
print(high)


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)


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 os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def prime_factors(x):
	s = set()
	n = x
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			s.add(i)
		i += 1
	if n > 1:
		s.add(n)
	return s
from collections import Counter
import heapq
import math
from collections import Counter
from bisect import bisect_right
import heapq
import sys
input = sys.stdin.buffer.readline
import math

def f(g):
	l = g - 1
	r = g
	while l <= r:
		mid = (l + r) / 2
		if can(mid):
			anss = mid
			r = mid
		else:
			l = mid
		if l - r < 10 ** (-10):
			break

def can(x):
	for i in range(n):
		if i != 0:
			w = m + x
			x -= w / ls[i]
		w = m + x
		x -= w / arr[i]
		if x < 0:
			return False
	w = x + m
	x -= w / ls[0]
	if x < 0.0:
		return False
	return True
n = int(input())
m = int(input())
arr = list(map(int, input().split()))
ls = list(map(int, input().split()))
l = 0
ans = -1
r = 10 ** 9 + 100
anss = -1
while l + 1e-07 < r:
	mid = (l + r) / 2
	if can(mid):
		ans = mid
		r = mid
	else:
		l = mid
print(ans)
from collections import deque


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())
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())
ar = list(map(int, input().split()))
br = list(map(int, input().split()))
f = 0
for i in range(n):
	if ar[i] == 1 or br[i] == 1:
		f = 1
if f == 1:
	print(-1)
else:
	ch = 1
	for i in range(n):
		ch *= (ar[i] - 1) / ar[i]
		ch *= (br[i] - 1) / br[i]
	ans = m / ch - m
	print(ans)


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


import copy
from collections import Counter
n_planets = int(input())
weight = int(input())
data = []
for _ in range(2):
	data.append(list(map(int, input().split())))
data = list(reversed(data))
if min(data[0]) == 1 or min(data[1]) == 1:
	print(-1)
else:
	gas_old = 0
	gas_old += (gas_old + weight) / (data[0][0] - 1)
	for i in range(1, n_planets):
		gas_old += (gas_old + weight) / (data[1][i] - 1)
		gas_old += (gas_old + weight) / (data[0][i] - 1)
	gas_old += (gas_old + weight) / (data[1][0] - 1)
	print(gas_old)


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())
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))


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)


import sys

def __starting_point():
	n = int(sys.stdin.readline().strip())
	m = int(sys.stdin.readline().strip())
	eps = 2e-07
	(off, land) = ([], [])
	off = list(map(int, sys.stdin.readline().strip().split(' ')))
	land = list(map(int, sys.stdin.readline().strip().split(' ')))
	if 1 in off or 1 in land:
		print(-1)
	else:
		(l, r) = (0, 10 ** 9)

		def is_ok(target):
			total = m + target
			remain = total
			for i in range(n):
				remain -= remain / off[i]
				if remain < m and abs(remain - m) > eps:
					return False
				remain -= remain / land[(i + 1) % n]
				if remain < m and abs(remain - m) > eps:
					return False
			return True
		while True:
			mid = (l + r) / 2
			if abs(r - l) <= eps:
				print(mid)
				break
			if is_ok(mid):
				r = mid
			else:
				l = mid
__starting_point()


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())
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 = list(map(int, input().split()))
B = list(map(int, input().split()))
imp = fuel = 0
for i in range(N, 0, -1):
	if i == N:
		i = 0
	if B[i] == 1:
		imp = 1
		break
	fuel += (M + fuel) / (B[i] - 1)
	if A[i - 1] == 1:
		imp = 1
		break
	fuel += (M + fuel) / (A[i - 1] - 1)
print(-1 if imp else '{:.7f}'.format(fuel))


n = int(input())
p = int(input())
arr1 = list(map(int, input().split(' ')))
arr2 = list(map(int, input().split(' ')))
a = 1
flag = False
for i in range(n):
	a *= (arr1[i] - 1) * (arr2[i] - 1) / (arr1[i] * arr2[i])
	if a == 0:
		flag = True
		break
if flag:
	print(-1)
else:
	print(p * ((1 - a) / a))


n = int(input())
m = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
low = 1
high = 1000000000
ans = -1
while low <= high:
	if high - low < 1e-06:
		low = high
	mid = low + (high - low) / 2
	try_val = mid
	init_wt = m + try_val
	isPossible = True
	for i in range(n):
		req1 = init_wt / a[i]
		try_val -= req1
		if try_val <= 0:
			isPossible = False
			break
		j = (i + 1) % n
		init_wt -= req1
		req2 = init_wt / b[j]
		try_val -= req2
		if try_val < 0 or (i < n - 1 and try_val == 0):
			isPossible = False
			break
		init_wt -= req2
	if isPossible:
		ans = mid
		high = mid - 1e-06
	else:
		low = mid + 1e-06
if ans == -1:
	isPossible = True
	try_val = 1000000000.000001
	init_wt = m + try_val
	for i in range(n):
		req1 = init_wt / a[i]
		try_val -= req1
		if try_val <= 0:
			isPossible = False
			break
		j = (i + 1) % n
		init_wt -= req1
		req2 = init_wt / b[j]
		try_val -= req2
		if try_val < 0 or (i < n - 1 and try_val == 0):
			isPossible = False
			break
		init_wt -= req2
	if isPossible:
		ans = 1000000000
print(ans)


n = int(input())
m = float(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
if min(a) == 1 or min(b) == 1:
	print(-1)
else:
	C = 1.0
	for i in a:
		C *= i
		C /= i - 1
	for i in b:
		C *= i
		C /= i - 1
	print(m * (C - 1.0))


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())
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)


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 = [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)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
m = iinp()
im = m
a = lmp()
b = lmp()
if 1 in a + b:
	print(-1)
	exit()
ans = 0
x = m / (b[0] - 1)
m += x
for i in range(n - 1, 0, -1):
	m += m / (a[i] - 1)
	m += m / (b[i] - 1)
print(m + m / (a[0] - 1) - im)


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, m) = (int(input()), int(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(b[0])
del b[0]
c = m
for i in range(n - 1, -1, -1):
	if b[i] == 1 or a[i] == 1:
		print(-1)
		break
	m += m / (b[i] - 1)
	m += m / (a[i] - 1)
else:
	print(m - c)


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
readline = sys.stdin.readline
N = int(readline())
M = float(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
B = B[1:] + [B[0]]
C = []
for (a, b) in zip(A[::-1], B[::-1]):
	C.append(b)
	C.append(a)
if 1 in C:
	print(-1)
else:
	M0 = M
	for c in C:
		M += M / (c - 1)
	print(M - M0)


rd = lambda : list(map(int, input().split()))
(n, m) = (rd(), rd()[0])
r = m
for x in rd() + rd():
	if x > 1:
		r *= x
		r /= x - 1
	else:
		print(-1)
		return
print(r - m)


def f(arr, p, W):
	fuel = p
	for i in range(N):
		expend = (fuel + W) / arr[i][0]
		fuel -= expend
		expend = (fuel + W) / arr[(i + 1) % N][1]
		fuel -= expend
		if fuel < 0:
			return False
	return fuel >= 0
N = int(input())
W = int(input())
arr = [[0] * 2 for row in range(N)]
line = input().split()
for i in range(N):
	arr[i][0] = int(line[i])
line = input().split()
for i in range(N):
	arr[i][1] = int(line[i])
a = 0
b = 1000000001
while b - a > 1e-06:
	p = (b + a) / 2
	if f(arr, p, W):
		b = p
	else:
		a = p
if a <= 1000000000:
	print(a)
else:
	print(-1)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = 0
k = 0
for i in range(len(b)):
	t = b[len(b) - i - 1]
	try:
		x = (t * d + m) / (t - 1)
	except:
		k = 1
		break
	d = x
	y = a[len(a) - i - 1]
	try:
		p = (y * d + m) / (y - 1)
	except:
		k = 1
		break
	d = p
print(p if k != 1 else -1)


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 = 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 mi():
	return map(int, input().split())
n = int(input())
m = int(input())
a = list(mi())
b = list(mi())
low = 0
high = 10 ** 15 + 1
ans = high
while low <= high:
	mid = (low + high) / 2
	nm = m + mid / 10 ** 6
	onm = nm
	for i in range(n):
		nm -= nm / a[i]
		nm -= nm / b[(i + 1) % n]
	if nm - m >= 0:
		ans = min(ans, mid)
		high = mid - 1
	else:
		low = mid + 1
if ans == 10 ** 15 + 1:
	mid = 10 ** 15
	nm = m + mid / 10 ** 6
	onm = nm
	for i in range(n):
		nm -= nm / a[i]
		nm -= nm / b[(i + 1) % n]
	if nm - m >= -10 ** (-6):
		print(mid / 10 ** 6)
	else:
		print(-1)
else:
	print(ans / 10 ** 6)


n = int(input())
m = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = []
for i in range(n - 1, -1, -1):
	z.append(x[i])
	z.append(y[i])
z = [z[-1]] + z[:-1]
s = m
for i in z:
	if i <= 1:
		print(-1)
		exit()
	else:
		s += s / (i - 1)
print(s - m)


import sys

def bits(n: int):
	return list(bin(n)).count('1')

def main(test_case=False):
	n = int(input()) if test_case else 1
	for _ in range(n):
		test()

def flush():
	sys.stdout.flush()

def parr(arr):
	print(*arr, sep=' ')

def gcd(a, b):
	while b:
		if b % a == 0:
			break
		tmp = a
		a = b % a
		b = tmp
	return a

def solve(m, x):
	return m + m / (x - 1)

def test():
	n = int(input())
	m = int(input())
	c = m
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for x in a:
		if x == 1:
			print(-1)
			exit()
	for x in b:
		if x == 1:
			print(-1)
			exit()
	for i in range(n):
		m = solve(m, b[-i])
		m = solve(m, a[-i - 1])
	ans = m - c
	print('{:.9f}'.format(ans))
main(False)


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()


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()))

def canFly(c):
	c += m
	for i in range(n):
		if i != 0:
			cost = c / b[i]
			c -= cost
		if i != n - 1:
			cost = c / a[i]
			c -= cost
		if c <= m:
			return False
	cost = c / a[n - 1]
	c -= cost
	cost = c / b[0]
	c -= cost
	if c < m:
		return False
	return True
(l, r) = (1, 10 ** 18)
flag = 0
while abs(l - r) > 10 ** (-6):
	mid = (l + r) / 2
	if canFly(mid):
		r = mid
		flag = 1
	else:
		l = mid
if flag == 0:
	print(-1)
else:
	print(l)


NPlanetas = int(input())
MasaCohete = int(input())
CoeficientesDespegue1 = input()
CoeficientesLanding1 = input()
CoeficientesDespegue = [float(i) for i in CoeficientesDespegue1.split(' ')]
CoeficientesLanding = [float(i) for i in CoeficientesLanding1.split(' ')]
landing = -1
takeoff = 1
NPlanetas = int(NPlanetas)
MasaCohete = int(MasaCohete)
try:
	W = float(MasaCohete)
	W = W * (1 / (1 - 1 / float(CoeficientesLanding[0])))
	for i in range(1, NPlanetas):
		if landing == 1:
			W = W * (1 / (1 - 1 / float(CoeficientesLanding[NPlanetas - i])))
		if takeoff == 1:
			W = W * (1 / (1 - 1 / float(CoeficientesDespegue[NPlanetas - i])))
		landing = landing * -1
		takeoff = takeoff * -1
		if landing == 1:
			W = W * (1 / (1 - 1 / float(CoeficientesLanding[NPlanetas - i])))
		if takeoff == 1:
			W = W * (1 / (1 - 1 / float(CoeficientesDespegue[NPlanetas - i])))
		landing = landing * -1
		takeoff = takeoff * -1
	W = W * (1 / (1 - 1 / float(CoeficientesDespegue[0])))
	W = W - MasaCohete
	print(W)
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 = input()
n = int(n)
m = input()
m = int(m)
a_ = input()
a = [float(i) for i in a_.split(' ')]
b_ = input()
b = [float(i) for i in b_.split(' ')]
u = []
for i in range(0, len(b) - 1):
	u.append(b[i + 1])
u.append(b[0])
b = u
comb = 0
for i in range(1, n + 1):
	if b[n - i] - 1 == 0 or a[n - i] - 1 == 0:
		print(-1)
		break
	else:
		comb = comb + m / (b[n - i] - 1)
		m = m + m / (b[n - i] - 1)
		comb = comb + m / (a[n - i] - 1)
		m = m + m / (a[n - i] - 1)
		if i == n:
			print(comb)


def f(k, x):
	return (m + x) / k

def g(c):
	for i in range(n):
		c -= f(a[i], c)
		c -= f(b[i], c)
	return c
I = input
(n, m, l, r) = (int(I()), int(I()), 0, 1000000000.0)
(*a,) = map(int, I().split())
(*b,) = map(int, I().split())
if g(1000000000.0 + 1e-06) < 0:
	print(-1)
	exit()
while r - l > 1e-06:
	w = (r + l) / 2
	c = g(w)
	if c > 0:
		r = w
	elif c < 0:
		l = w
	else:
		print(w)
		exit()
print(w)


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, 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)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def possible(x):
	for i in range(n):
		if i != 0:
			weight = x + rocket
			x -= weight / landing[i]
		weight = x + rocket
		x -= weight / takeoff[i]
		if x < 0:
			return False
	weight = x + rocket
	x -= weight / landing[0]
	if x < 0:
		return False
	return True
n = Int()
rocket = Int()
takeoff = array()
landing = array()
low = 0
high = 10 ** 10
ans = -1
while low + 1e-07 < high:
	mid = (low + high) / 2
	if possible(mid):
		ans = mid
		high = mid
	else:
		low = mid
print(ans)


R = lambda : map(int, input().split())
n = int(input())
m = int(input())
(a, b) = (list(R()), list(R()))
b = b[1:] + b[:1]
(l, r) = (0, 2 * 10 ** 9)
while (r - l) / max(1, r) >= 1e-07 and l < 10 ** 9 + 1:
	rem = mid = (l + r) / 2
	for i in range(n):
		rem -= (m + max(0, rem)) / a[i]
		rem -= (m + max(0, rem)) / b[i]
	if rem < 0:
		l = mid
	else:
		r = mid
print(l if l < 10 ** 9 + 1 else -1)


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())
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))


from decimal import *
getcontext().prec = 28
(n, m) = (int(input()), int(input()))
lift = list(map(int, input().split()))
drop = list(map(int, input().split()))
fuel = 0
if drop[0] == 1:
	exit(print(-1))
else:
	r = Decimal(m) / Decimal(drop[0] - 1)
	m += r
	fuel += r
lift = lift[::-1]
drop = drop[::-1]
for i in range(n - 1):
	if lift[i] == 1:
		exit(print(-1))
	else:
		r = Decimal(m) / Decimal(lift[i] - 1)
		m += r
		fuel += r
	if drop[i] == 1:
		exit(print(-1))
	else:
		r = Decimal(m) / Decimal(drop[i] - 1)
		m += r
		fuel += r
if lift[n - 1] == 1:
	exit(print(-1))
else:
	r = Decimal(m) / Decimal(lift[n - 1] - 1)
	m += r
	fuel += r
print(fuel)


(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)


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


import sys
import math

def solution(n, m, a, b):
	a += [a[0]]
	b += [b[0]]
	mass = [0] * len(a)
	mass[len(a) - 1] = m
	for i in range(len(a) - 1, 0, -1):
		tmp = mass[i]
		if b[i] - 1 <= 0:
			return -1
		extra_fuel = tmp / (b[i] - 1)
		tmp += extra_fuel
		if a[i - 1] - 1 <= 0:
			return -1
		extra_fuel = tmp / (a[i - 1] - 1)
		tmp += extra_fuel
		mass[i - 1] = tmp
	return mass[0] - m
n = int(sys.stdin.readline().rstrip())
m = int(sys.stdin.readline().rstrip())
a = [int(x) for x in sys.stdin.readline().rstrip().split()]
b = [int(x) for x in sys.stdin.readline().rstrip().split()]
res = solution(n, m, a, b)
sys.stdout.write(str(res))


n = int(input())
m = int(input())
R = lambda : list(map(float, input().split()))
a = R()
b = R()
if min(a) <= 1 or min(b) <= 1:
	print(-1)
	exit(0)
ans = 1
for i in range(n):
	ans *= a[i] / (a[i] - 1) * b[i] / (b[i] - 1)
print('{:.10f}'.format((ans - 1) * m))


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = m
for i in range(n):
	if a[i] <= 1 or b[i] <= 1:
		print(-1)
		exit()
s += s / (a[0] - 1)
for i in range(n - 1, 0, -1):
	s += s / (b[i] - 1)
	s += s / (a[i] - 1)
s += s / (b[0] - 1)
print('%.10f' % (s - m))


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(l, r) = (0, 10 ** 9 + 5)
e = 10 ** (-6)
while r - l > e:
	m1 = (r + l) / 2
	mm = m1
	now = mm + m
	kek = now / a[0]
	mm -= kek
	if mm < 0:
		l = m1
		continue
	flag = True
	for i in range(1, n):
		now = mm + m
		kek = now / a[i]
		mm -= kek
		if mm < 0:
			flag = False
			break
		now = mm + m
		kek = now / b[i]
		mm -= kek
		if mm < 0:
			flag = False
			break
	if not flag:
		l = m1
		continue
	now = mm + m
	kek = now / b[0]
	mm -= kek
	if mm < 0:
		l = m1
		continue
	r = m1
if r > 10 ** 9 + 1:
	print(-1)
else:
	print(r)


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)


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')


import sys
planets = int(input())
M = int(input())
Fuel = 0
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for x in a:
	if x == 1:
		print('-1')
		sys.exit()
for x in b:
	if x == 1:
		print('-1')
		sys.exit()
overall = []
for i in range(planets):
	overall.append(a[i])
	overall.append(b[i])
for i in overall:
	if Fuel > 1000000000:
		pass
	x = (M + Fuel) / (i - 1)
	Fuel += x
print(Fuel)


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)


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()))
(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 = 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())
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)


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 sys
n = int(input())
m = float(input())
a = list(map(float, input().split()))
b = list(map(float, input().split()))
for i in a:
	if i <= 1.0:
		print(str(-1))
		return
for i in b:
	if i <= 1.0:
		print(str(-1))
		return
s = m
s += s / (b[0] - 1.0)
for i in range(n - 1, 0, -1):
	s += s / (a[i] - 1.0)
	s += s / (b[i] - 1.0)
s += s / (a[0] - 1.0)
print('{0:.10f}'.format(s - m))


import sys
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)
	sys.exit(0)
f = m / (b[0] - 1)
for i in range(n - 1, 0, -1):
	f += (m + f) / (a[i] - 1)
	f += (m + f) / (b[i] - 1)
f += (m + f) / (a[0] - 1)
print(f)


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))


from sys import stdin
import collections
import copy
import math
n = int(stdin.readline())
m = int(stdin.readline())
up = list(map(int, stdin.readline().split()))
down = list(map(int, stdin.readline().split()))

def check(x):
	weight = m + x
	fuel = x
	for i in range(n):
		f = weight / up[i]
		if fuel < f:
			return False
		else:
			weight -= f
			fuel -= f
		f = weight / down[i]
		if fuel < f:
			return False
		else:
			weight -= f
			fuel -= f
	return True
l = 0
r = 1000000000.0 + 1e-06
for ii in range(100):
	mid = (r + l) / 2
	if check(mid):
		r = mid
	else:
		l = mid
	if r - l <= 1e-10:
		break
if l >= 1000000000.0 + 1e-06:
	print(-1)
else:
	print('%.10f' % l)


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))


(n, m) = (int(input()), int(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 1.0
for x in a:
	ans -= ans / x
for x in b:
	ans -= ans / x
if ans == 0:
	print(-1)
else:
	ans = 1 / ans
	ans = ans * m - m
	ans += 5e-10
	print('%.10f' % ans)


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())
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())
aa = list(map(int, input().split(' ')))
bb = list(map(int, input().split(' ')))
vs = list(zip(aa, bb[1:] + [bb[0]]))
vs = [v for pair in vs for v in pair]
if min(vs) <= 1:
	print(-1)
	exit(0)
r = m
for k in reversed(vs):
	r = r * k / (k - 1)
print(r - m)


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)


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)


def gcd(x, y):
	if x < y:
		return gcd(y, x)
	if not x % y:
		return y
	return gcd(y, x % y)
n = int(input())
m = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
if 1 in arr or 1 in brr:
	print(-1)
else:
	ml = 1
	dv = 1
	for x in arr:
		ml *= x
		dv *= x - 1
		d = gcd(ml, dv)
		ml /= d
		dv /= d
	for x in brr:
		ml *= x
		dv *= x - 1
		d = gcd(ml, dv)
		ml /= d
		dv /= d
	print(ml * m / dv - 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()))
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)


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)


import sys
import os

def test(weight, a, b, fuel):
	for i in range(len(a) - 1):
		cost1 = (weight + fuel) / a[i]
		if fuel < cost1:
			return False
		fuel -= cost1
		cost2 = (weight + fuel) / b[i + 1]
		if fuel < cost2:
			return False
		fuel -= cost2
	cost1 = (weight + fuel) / a[len(a) - 1]
	if fuel < cost1:
		return False
	fuel -= cost1
	cost2 = (weight + fuel) / b[0]
	if fuel < cost2:
		return False
	fuel -= cost2
	return True

def solve(weight, a, b):
	if not test(weight, a, b, 10 ** 9 + 1):
		return -1
	left = 0
	right = 10 ** 9 + 1
	error = 1 / 10 ** 6
	while right - left > error:
		mid = (left + right) / 2
		if test(weight, a, b, mid):
			right = mid
		else:
			left = mid
		error = min(1 / 10 ** 6, right / 10 ** 7)
	return right

def main():
	n = int(input())
	weight = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(weight, a, b))
main()


from math import ceil

def test(f):
	for i in range(n):
		if r1 + f > f * lift[i]:
			return 0
		f -= (r1 + f) / lift[i]
		if r1 + f > f * land[i + 1]:
			return 0
		f -= (r1 + f) / land[i + 1]
	return 1
p = int(input())
total_wgt = int(input())
r1 = total_wgt
lift = list(map(int, input().split()))
land = list(map(int, input().split()))
n = len(land)
ans = 1e+20
lift += [lift[0]]
land += [land[0]]
l = 0.0
r = 1e+20
for i in range(1000):
	mid = (l + r) / 2.0
	if test(mid):
		r = mid
	else:
		l = mid
if r < 1e+19:
	print('%.17f' % r)
else:
	print(-1)


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())
m = float(input())
a = list(map(float, input().split()))
b = list(map(float, input().split()))
a += (a[0],)
b += (b[0],)
lo = 0.0
hi = 1e+20

def test(f):
	for i in range(n):
		if m + f > f * a[i]:
			return 0
		f -= (m + f) / a[i]
		if m + f > f * b[i + 1]:
			return 0
		f -= (m + f) / b[i + 1]
	return 1
for _ in range(100):
	mid = (lo + hi) / 2.0
	if test(mid):
		hi = mid
	else:
		lo = mid
if hi < 1e+19:
	print('%.17f' % hi)
else:
	print(-1)


def flight_cost(mass, cost):
	return mass / (cost - 1)

class CodeforcesTask1010ASolution:

	def __init__(self):
		self.result = ''
		self.planet_count = 0
		self.payload = 0
		self.takeoff_costs = []
		self.landing_costs = []

	def read_input(self):
		self.planet_count = int(input())
		self.payload = int(input())
		self.takeoff_costs = [int(x) for x in input().split(' ')]
		self.landing_costs = [int(x) for x in input().split(' ')]

	def process_task(self):
		try:
			payload = self.payload
			required_fuel = 0
			nf = flight_cost(payload, self.landing_costs[0])
			required_fuel += nf
			payload += nf
			for x in range(1, self.planet_count):
				nf = flight_cost(payload, self.takeoff_costs[self.planet_count - x])
				required_fuel += nf
				payload += nf
				nf = flight_cost(payload, self.landing_costs[self.planet_count - x])
				required_fuel += nf
				payload += nf
			nf = flight_cost(payload, self.takeoff_costs[0])
			required_fuel += nf
			payload += nf
			self.result = str(required_fuel)
		except ZeroDivisionError:
			self.result = '-1'

	def get_result(self):
		return self.result
Solution = CodeforcesTask1010ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


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


a = int(input())
b = int(input())
c = input().split()
d = input().split()
s = 10 ** 9
last = 0
while True:
	t = s
	lasts = s
	for i in range(a):
		t = t - (b + t) / int(d[i])
		t = t - (b + t) / int(c[i])
	if t < 0:
		lasst = s
		s = s + (s - last) / 2
		last = lasst
	else:
		s = (s + last) / 2
	if s == lasts:
		if s > 10 ** 9 + 1:
			print(-1)
		else:
			print(s)
		break


def fly():
	n = int(input())
	weight = int(input())
	lift = [int(k) for k in input().split()]
	land = [int(k) for k in input().split()]
	fuel_to_take = weight
	for i in range(n):
		if lift[i] <= 1 or land[i] <= 1:
			return -1
		fuel_to_take += fuel_to_take / (lift[i] - 1)
		fuel_to_take += fuel_to_take / (land[i] - 1)
	return fuel_to_take - weight
print(fly())


t = int(input())
mass = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
flag = 1
for i in range(t):
	if arr[i] == 1 or brr[i] == 1:
		flag = 0
		break
if flag:
	ans = mass * brr[0] / (brr[0] - 1)
	for i in range(t - 1, 0, -1):
		ans = ans * arr[i] / (arr[i] - 1)
		ans = ans * brr[i] / (brr[i] - 1)
	ans = ans * arr[0] / (arr[0] - 1)
	print(ans - mass)
else:
	print('-1')


INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n,) = I()
(m,) = I()
a = I()
b = I()
(lo, hi) = (0, INF)
if 1 in a or 1 in b:
	print(-1)
	exit()
eps = 10 ** (-6)
iter = 1000
while iter:
	iter -= 1
	mid = (lo + hi) / 2
	cur = mid
	for i in range(n):
		land = (cur + m) / b[i]
		if i == 0:
			land = 0
		cur -= land
		take_off = (cur + m) / a[i]
		cur -= take_off
		if cur < 0:
			break
	cur -= (cur + m) / b[0]
	if cur >= 0:
		hi = mid
	else:
		lo = mid
print(lo)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	M = getInt()
	A = getInts()
	B = getInts()
	right = 10 ** 9 + 3
	left = 0

	def works(x):
		w = M + x
		for i in range(N):
			x -= w / A[i]
			if x < 0:
				return False
			w = M + x
			x -= w / B[(i + 1) % N]
			if x < 0:
				return False
			w = M + x
		return x >= 0
	while right - left > 10 ** (-6):
		middle = (left + right) / 2
		if works(middle):
			right = middle
		else:
			left = middle
	return right if right <= 10 ** 9 + 0.01 else -1
print(solve())


n = int(input())
m = int(input())
a = list(map(float, input().split()))
b = list(map(float, input().split()))
i = n
f = 0
while i >= 1:
	if a[i - 1] != 1 and b[i - 1] != 1:
		f = 1 / (1 - 1 / a[i - 1]) * (f + m / a[i - 1])
		f = 1 / (1 - 1 / b[i - 1]) * (f + m / b[i - 1])
		i -= 1
	else:
		break
if f <= 10 ** 9 and i == 0:
	print(f)
else:
	print(-1)


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())
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 = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
p = 1
q = 1
for i in range(n):
	aa = a[i]
	bb = b[(i + 1) % n]
	p *= (aa - 1) * (bb - 1)
	q *= aa * bb
print(-1 if p == 0 else m * q / p - m)


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())
p = int(input())
R = lambda : map(int, input().split())
a = list(R())
b = list(R())
t = 1
for i in range(n):
	t *= (1 - 1 / a[i]) * (1 - 1 / b[i])
if t >= 1 or t == 0:
	print(-1)
else:
	print(p * ((1 - t) / t))


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())
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)


n = int(input())
m = int(input())
to = list(map(int, input().split()))
ld = list(map(int, input().split()))
flag = 0
for i in to:
	if i == 1:
		flag = 1
for i in ld:
	if i == 1:
		flag = 1
if flag == 1:
	print('-1')
else:
	p = m
	ans = 0
	ans = p / (ld[0] - 1)
	p += ans
	i = 0
	for i in range(0, n - 2):
		ans = p / (to[i + 1] - 1)
		p += ans
		ans = p / (ld[i + 1] - 1)
		p += ans
	ans = p / (to[n - 1] - 1)
	p += ans
	ans = p / (ld[n - 1] - 1)
	p += ans
	ans = p / (to[0] - 1)
	p += ans
	print(p - m)


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


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 any((i == 1 for i in a)) or any((i == 1 for i in b)):
	print('-1')
else:
	ans = 1.0
	for i in range(n):
		ans -= ans / a[i]
		if i == n - 1:
			ans -= ans / b[0]
		else:
			ans -= ans / b[i + 1]
	ans = m / ans
	print(ans - m)


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)


def sol(a):
	a += m
	for i in range(n):
		x = aa[i]
		if i == n - 1:
			y = bb[0]
		else:
			y = bb[i + 1]
		a -= a / x
		if a < m:
			return a - m
		a -= a / y
		if a < m:
			return a - m
	return a - m
n = int(input())
m = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
low = 0
high = 10 ** 9 + 1
ep = 10 ** (-9)
ans = -1
while low < high:
	mid = (low + high) / 2
	left = sol(mid)
	if left < 0:
		low = mid
		continue
	if left < ep:
		ans = mid
		break
	else:
		high = mid
print(ans)


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 = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
	if a[i] == 1 or b[i] == 1:
		print(-1)
		exit(0)
sum = m / (b[0] - 1)
for i in range(n - 1, 0, -1):
	sum += (m + sum) / (a[i] - 1)
	sum += (m + sum) / (b[i] - 1)
sum += (m + sum) / (a[0] - 1)
print('%.11f' % sum)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque

def check(t, m):
	x = m + t
	for i in range(1, n + 1):
		x -= x / a[i]
		x -= x / b[i]
		if x < m:
			return False
	return True
n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.append(a[0])
b.append(b[0])
l = 0
r = pow(10, 10)
for i in range(n):
	if a[i] <= 1 or b[i] <= 1:
		print(-1)
		exit()
for i in range(500):
	mid = (l + r) / 2
	if check(mid, m):
		r = mid
	else:
		l = mid
print(l)


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
k = m
i = 0
j = 1
ans = 0
c = 1
while i >= 0 and i < n:
	try:
		if j == 1:
			ans = m / (b[i] - 1)
		else:
			ans = m / (a[i] - 1)
	except:
		print(-1)
		break
	m += ans
	j = 0 if j == 1 else 1
	i += c
	if i == n:
		c = -c
		i -= 1
else:
	print('{0:.10f}'.format(m - k))


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())
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)