using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Int32.Parse(Console.ReadLine());
            var res = -1;
            for(var i = 0; i < n; ++i)
                switch (Console.ReadLine())
                {
                    case "Tetrahedron": res += 4; break;
                    case "Cube": res += 6; break;
                    case "Octahedron": res += 8; break;
                    case "Dodecahedron": res += 12; break;
                    case "Icosahedron": res += 20; break;
                }
            Console.WriteLine(res + 1);
        }
    }
}


using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Int32.Parse(Console.ReadLine());
            var res = -1;
            for(var i = 0; i < n; ++i)
                switch (Console.ReadLine())
                {
                    case "Tetrahedron": res += 4; break;
                    case "Cube": res += 6; break;
                    case "Octahedron": res += 8; break;
                    case "Dodecahedron": res += 12; break;
                    case "Icosahedron": res += 20; break;
                }
            Console.WriteLine(res);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Olymp
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            long sum = 0;
            n = Convert.ToInt32(Console.ReadLine());

            for(int i = 0; i < n; i++)
            {
                string input = Console.ReadLine();
                switch(input[0])
                {
                    case 'T': sum += 4; break;
                    case 'C': sum += 6;  break;
                    case 'O': sum += 8; break;
                    case 'D': sum += 12; break;
                    case 'I': sum += 20;  break;

                }
            }
            Console.WriteLine(sum);
        }
    }
}


using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var n = cin.NextInt();
			long sum = 0;
			for (int i = 0; i < n; i++)
			{
				var str = cin.NextString();
				if (str == "Tetrahedron")
				{
					sum += 4;
				}
				else if (str == "Cube")
				{
					sum += 6;
				}
				else if (str == "Octahedron")
				{
					sum += 8;
				}
				else if (str == "Dodecahedron")
				{
					sum += 12;
				}
				else if (str == "Icosahedron")
				{
					sum += 20;
				}
				else
				{
					var z = 5;
				}
			}
			Console.WriteLine(sum);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			var inputText = File.ReadAllText(@"..\..\input.txt");
			var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
			var consoleOut = Console.Out;
			for (var i = 0; i < testCases.Length; i++)
			{
				var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
				Console.SetIn(new StringReader(parts[0].Trim()));
				var stringWriter = new StringWriter();
				Console.SetOut(stringWriter);
				var sw = Stopwatch.StartNew();
				new Template().Solve();
				sw.Stop();
				var output = stringWriter.ToString();

				Console.SetOut(consoleOut);
				var color = ConsoleColor.Green;
				var status = "Passed";
				if (parts[1].Trim() != output.Trim())
				{
					color = ConsoleColor.Red;
					status = "Failed";
				}
				Console.ForegroundColor = color;
				Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
			}
			Console.ReadLine();
			Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#endif
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}


        using System;
        using System.Collections.Generic;
        using System.Globalization;
        using System.Linq;
        using System.Text;
        using System.Threading;
        using System.Threading.Tasks;

        namespace Training_App
        {
            class Program
            {

            static void Main(string[] args)
            {
            int number = int.Parse(Console.ReadLine());
            List<String> shapes = new List<string>();
            for (int i = 0; i < number; i++)
            {
                shapes.Add(Console.ReadLine());
            }

            int Tetrahedron = 4;
            int Cube = 6;
            int Octahedron = 8;
            int Dodecahedron = 12;
            int Icosahedron = 20;

            int result = 0;

            for (int i = 0; i < number; i++)
            {
                switch(shapes[i])
                {
                    case "Tetrahedron":
                        result += Tetrahedron;
                        break;
                    case "Cube":
                        result += Cube;
                        break;
                    case "Octahedron":
                        result += Octahedron;
                        break;
                    case "Dodecahedron":
                        result += Dodecahedron;
                        break;
                    case "Icosahedron":
                        result += Icosahedron;
                        break;
                    default:
                        break;
                }

            }

            Console.WriteLine(result);

            }

            }

            }


using System;
using System.Collections.Generic;

class A785 {
    static Dictionary<string, int> Face = new Dictionary<string, int> {
        {"Tetrahedron", 4},
        {"Cube", 6},
        {"Octahedron", 8},
        {"Dodecahedron", 12},
        {"Icosahedron", 20}
    };

    public static void Main() {
        var n = int.Parse(Console.ReadLine());
        int ans = 0;
        for (int i = 0; i < n; ++i)
            ans += Face[Console.ReadLine()];
        Console.WriteLine(ans);
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QT
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s;
            int sum = 0;
            for(var i = 0; i< n; i++)
            {
                s = Console.ReadLine();
                if (s == "Tetrahedron")
                {
                    sum += 4;
                }
                else
                {
                    if(s == "Cube")
                    {
                        sum += 6;
                    }
                    else
                    {
                        if(s == "Tetrahedron")
                        {
                            sum += 8;
                        }
                        else
                        {
                            if(s == "Dodecahedron")
                            {
                                sum += 12;
                            }
                            else
                            {
                                if(s == "Icosahedron")
                                {
                                    sum += 20;
                                }
                            }
                        }
                    }
                }
            }
            Console.WriteLine(sum);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QT
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = new string[n]; ;
            int sum = 0;

            for(int g = 0; g< n;g++)
            {
                s[g] = Console.ReadLine();
            }

            for (int i = 0; i < n; i++)
            {

                if (s[i] == "Tetrahedron")
                {
                    sum += 4;
                }
                else
                {
                    if(s[i] == "Cube")
                    {
                        sum += 6;
                    }
                    else
                    {
                        if(s[i] == "Octahedron")
                        {
                            sum += 8;
                        }
                        else
                        {
                            if(s[i] == "Dodecahedron")
                            {
                                sum += 12;
                            }
                            else
                            {
                                if(s[i] == "Icosahedron")
                                {
                                    sum += 20;
                                }
                            }
                        }
                    }
                }
            }
            Console.WriteLine(sum);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QT
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int sum = 0;
            for(var i = 0; i< n; i++)
            {
                if(s[i]== "Tetrahedron")
                {
                    sum += 4;
                }
                else
                {
                    if(s[i]== "Cube")
                    {
                        sum += 6;
                    }
                    else
                    {
                        if(s[i]== "Tetrahedron")
                        {
                            sum += 8;
                        }
                        else
                        {
                            if(s[i]== "Dodecahedron")
                            {
                                sum += 12;
                            }
                            else
                            {
                                if(s[i]== "Icosahedron")
                                {
                                    sum += 20;
                                }
                            }
                        }
                    }
                }
            }
            Console.WriteLine(sum);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace testiki
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = Int64.Parse(Console.ReadLine());
            long[] x = Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray();
            long socks = 0;
            long CurrentSocks = 0;

            long[] Nsocks = new long[n];

            for(long i=0;i<2*n; i++)
            {
                if(Nsocks[x[i]-1]==0)
                {
                    CurrentSocks++;
                    Nsocks[x[i]-1]++;
                }
                else
                {
                    if(Nsocks[x[i]-1] == 1)
                    {
                        Nsocks[x[i]-1]++;
                        CurrentSocks--;
                    }
                }
                socks = Math.Max(socks, CurrentSocks);

            }
            Console.WriteLine(socks);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace anadmn
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0, count = 0;
            string buffer = string.Empty;

            n = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                buffer = Console.ReadLine();
                if (buffer[0] == 'T')
                {
                    count += 4;
                }
                else
                {
                    if (buffer[0] == 'C')
                    {
                        count += 6;
                    }
                    else
                    {
                        if (buffer[0] == 'O')
                        {
                            count += 8;
                        }
                        else
                        {
                            if (buffer[0] == 'D')
                            {
                                count += 12;
                            }
                            else
                            {
                                if (buffer[0] == 'I')
                                {
                                    count += 20;
                                }
                            }
                        }
                    }
                }
            }
            Console.WriteLine(count);
            Console.Read();
        }
    }
}


using System;

namespace _2
{
    class Program
    {
        private static void Main(string[] arg)
        {
            var n = int.Parse(Console.ReadLine());
			int m=0;
			for (int i=0; i<n; i++){
				var s = Console.ReadLine();
				if (s=="Tetrahedron"){
					m+=4;
				}
				else if (s=="Cube"){
					m+=6;
				}
				else if (s=="Octahedron"){
					m+=8;
				}
				else if (s=="Dodecahedron"){
					m+=12;
				}
				else if (s=="Icosahedron"){
					m+=20;
				}
			}
			Console.WriteLine(m);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int num, answer = 0;
            string test;
            try
            {
                // input: "{0}"
                num = Convert.ToInt32(Console.ReadLine());
                for (int i = 0; i < num; i++)
                {
                    test = Console.ReadLine();
                    switch (test)
                    {
                        case "Tetrahedron":
                            answer += 4;
                            break;
                        case "Cube":
                            answer += 6;
                            break;
                        case "Octahedron":
                            answer += 8;
                            break;
                        case "Dodecahedron":
                            answer += 12;
                            break;
                        case "Icosahedron":
                            answer += 20;
                            break;
                        default:
                            throw (new Exception());
                    }
                }
            }
            catch
            {
                Console.WriteLine("Invalid input");
                return;
            }
            Console.WriteLine(answer);
            Console.ReadKey();
        }
    }
}


using System;
using System.Numerics;

namespace ConsoleApplication4
{
    class Program
    {

        static void Main(string[] args)
        {
            BigInteger sum = 0;
            int n = int.Parse(Console.ReadLine());
            for(int i = 0; i<n;i++)
            {
                string figure = Console.ReadLine();
                if (figure == "Tetrahedron") sum += 4;
                if (figure == "Cube") sum += 6;
                if (figure == "Octahedron") sum += 8;
                if (figure == "Dodecahedron") sum += 12;
                if (figure == "Icosahedron") sum += 20;

            }
            Console.WriteLine(sum);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TaskA
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var num = 0;

            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                switch (s)
                {
                    case "Tetrahedron": {
                        num += 4;
                        break;
                    }
                    case "Cube": {
                        num += 6;
                        break;
                    }
                    case "Octahedron": {
                        num += 8;
                        break;
                    }
                    case "Dodecahedron": {
                        num += 12;
                        break;
                    }
                    case "Icosahedron": {
                        num += 20;
                        break;
                    }

                }

            }
            Console.Write(num);
            //var arr = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                string str = Console.ReadLine();
                if (str == "Tetrahedron") sum += 4;
                else if (str == "Cube") sum += 6;
                else if (str == "Octahedron") sum += 8;
                else if (str == "Dodecahedron") sum += 12;
                else if (str == "Icosahedron") sum += 20;
            }
            Console.WriteLine(sum);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int res = 0;

            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                if (s == "Tetrahedron")
                {
                    res += 4;
                }
                if (s == "Cube")
                {
                    res += 6;
                }
                if (s == "Octahedron")
                {
                    res += 8;
                }
                if (s == "Dodecahedron")
                {
                    res += 12;
                }
                if (s == "Icosahedron")
                {
                    res += 20;
                }

            }
            Console.WriteLine(res);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace polyhedrons
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());

            Dictionary<string, int> poly = new Dictionary<string, int>()
            {
            {"Tetrahedron", 4},
            {"Cube", 6},
            {"Octahedron", 8},
            {"Dodecahedron", 12},
            {"Icosahedron", 20}
            };

            int sum = 0;
            for (int i = 0; i < count; i++)
            {

                string data = Console.ReadLine();

                sum += poly[data];
            }

            Console.WriteLine(sum);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _781A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            int s = 0;
            for(int i = 0; i<x;i++)
            {
                string b = Console.ReadLine();
                switch(b)
                {
                    case "Tetrahedron": s += 4; break;
                    case "Cube": s +=6; break;
                    case "Octahedron": s += 8; break;
                    case "Dodecahedron": s += 12; break;
                    case "Icosahedron": s +=20; break;
                }
            }
            Console.WriteLine(s);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());

            string a1 = Console.ReadLine();
            string[] s = a1.Split(' ');
            int sum = 0;
            for(int i = 0; i<s.Length; i++)
            {
                sum += int.Parse(s[i]);
            }
            Console.WriteLine(sum / k);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.Anton_and_Polyhedrons
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] arr = new string[n];
            int sum = 0;
            for(int i=0;i<n;i++)
            {
                arr[i] = Console.ReadLine();
                if(arr[i]=="Tetrahedron")
                {
                    sum += 4;
                }
                else if(arr[i]=="Cube")
                {
                    sum += 6;
                }
                else if(arr[i]=="Octahedron")
                {
                    sum += 8;
                }
                else if(arr[i]=="Dodecahedron")
                {
                    sum += 12;
                }
                else if(arr[i]=="Icosahedron")
                {
                    sum += 20;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Class2
{
    void Main()
    {
        var l = new Dictionary<string, int>();
        l["Tetrahedron"] = 4;
        l["Cube"] = 6;
        l["Octahedron"] = 8;
        l["Dodecahedron"] = 12;
        l["Icosahedron"] = 20;
        int answer = 0;
        int trial = Int32.Parse(Console.ReadLine());
        for (int i = 0; i < trial; i++)
        {
            answer += l[Console.ReadLine()];
        }

        Console.WriteLine(answer);

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Class2
{
    static void Main()
    {
        var l = new Dictionary<string, int>();
        l["Tetrahedron"] = 4;
        l["Cube"] = 6;
        l["Octahedron"] = 8;
        l["Dodecahedron"] = 12;
        l["Icosahedron"] = 20;
        int answer = 0;
        int trial = Int32.Parse(Console.ReadLine());
        for (int i = 0; i < trial; i++)
        {
            answer += l[Console.ReadLine()];
        }

        Console.WriteLine(answer);

    }
}


using System;

namespace ConsoleApplication2
{
    class myclass
    {
        public static void Main(String[] args)
        {
            int firstLine = int.Parse(Console.ReadLine());
            string[] list = new string[firstLine];
            for (int i = 0; i < firstLine; i++)
            {
                list[i] = Console.ReadLine();
            }

            int sum = 0;

            foreach (var form in list)
            {
                if (form.Equals("Tetrahedron"))
                    sum += 4;
                else if (form.Equals("Cube"))
                    sum += 6;
                else if (form.Equals("Octahedron"))
                    sum += 8;
                else if (form.Equals("Dodecahedron"))
                    sum += 12;
                else
                {
                    sum += 20;
                }
            }

            Console.WriteLine(sum);
        }
    }
}


"""for p in range(int(input())):

	n,k=map(int,input().split(" "))
	number=input().split(" ")
	chances=[k for i in range(n)]

	prev=-1
	prev_updated=-1
	last_used=False
	toSub=0
	start=0

	prevSub=0

	if(number[0]=='1'):
		prev=0
		prev_updated=0
		start=1

	for i in range(start,n):

		if(number[i]=='1'):
		#	print("\ni",i,"\ntoSub",toSub,"\nprevUpadted",prev_updated,"\nprev",prev,"\nlast_used",last_used)
			f1=False
#			toSub+=1
			toSub=0

			zeros=i - prev_updated - 1

			if(last_used):
				zeros-=1

			#chances[i]-=toSub

			#print(prevSub,(i - prev - 1 ) +1)
			if(i - prev - 1 <= prevSub):
				chances[i]-= prevSub - (i - prev - 1 ) +1
				if(chances[i]<zeros):
					chances[i]=zeros
				toSub+= prevSub - (i - prev - 1 ) +1
				f1=True

			if(zeros==0 or chances[i]==0):
				prev_updated=i
				prev=i
				last_used=False
				prevSub=toSub
				continue
		#	print("\nchances:  ",chances[i],"\t\tzeroes :   ",zeros,"\t\tprevSub :",prevSub)

			if(chances[i]>zeros):
		#		print("\t\t\t\t1")
				number[i-zeros]='1'
				number[i]='0'
				prev_updated=i-zeros
				last_used=False
			elif(chances[i]==zeros):
		#		print("\t\t\t\t2")
				number[i]='0'
				number[i-chances[i]]='1'
				prev_updated=i-chances[i]
				last_used=True
			else:
		#		print("\t\t\t\t3")
				number[i]='0'
				number[i-chances[i]]='1'
				prev_updated=i-chances[i]
				last_used=True
			prev=i

			prevSub=toSub

			if(prev_updated>2 and f1):
				if(number[prev_updated]=='1' and number[prev_updated-1]=='0' and number[prev_updated-2]=='1'):
					last_used=False
				#if()

		#	print("\ni",i,"\ntoSub",toSub,"\nprevUpadted",prev_updated,"\nprev",prev,"\nlast_used",last_used)
		#	print(number)
		else:
			toSub=0

	print(*number)
#	print(chances)"""

"""class offer:
	def __init__(self, n, fre):
		self.num = n
		self.free = fre
		self.delta= n-fre

n,m,k=map(int,input().split(" "))

shovel=list(map(int,input().split(" ")))

#dicti={}

offers=[]
temp_arr=[False for i in range(n)]

for i in range(m):
	p,q=map(int,input().split(" "))
	if(p>k):
		continue
	offers.append(offer(p,q))
#	dicti[p]=q

#for i in dicti:
#	dicti[i].sort()

shovel.sort()
shovel=shovel[:k+1]

offers.sort(key=lambda x: x.delta/x.num,reverse=True)

bestoffer=[]

for i in offers:
	if(not temp_arr[i.num]):
		temp_arr[i.num]=True
		bestoffer.append(i)

cost=0

for i in bestoffer:

for p in range(int(input())):
	arr=list(input())

	n=len(arr)
	for i in range(n):
		arr[i]=ord(arr[i])-96

	arr.sort()

	arr1=arr[:n//2]
	arr2=arr[n//2:]
	arr=[]
	#print(arr,arr1,arr2)
	i1=n//2-1
	i2=n-i1-2

	while (i1!=-1 and i2!=-1):
		arr.append(arr1[i1])
		arr.append(arr2[i2])
		i1-=1
		i2-=1
	if(i1!=-1):
		arr.append(arr1[i1])
	elif(i2!=-1):
		arr.append(arr2[i2])

	#print(arr)

	s=""
	for i in range(n-1):
		if(abs(arr[i]-arr[i+1])==1):
			s=-1
			print("No answer")
			break
		else:
			s+=chr(arr[i]+96)

	if(s!=-1):
		s+=chr(arr[-1]+96)
		print(s)"""

"""
n,m=map(int,input().split(" "))

seti=[]
ans=[1 for i in range(n)]

for i in range(m):
	arr=list(map(int,input().split(" ")))

	if(arr[0]>1):
		seti.append(set(arr[1:]))
	else:
		m-=1

parent=[-1 for i in range(m)]
#print(seti)
for i in range(m-1):
	for j in range(i+1,m):
		if(parent[j]==-1):
			if(len(seti[i].intersection(seti[j]))>0):
				seti[i]=seti[i].union(seti[j])
				parent[j]=i

#print(parent)

for i in range(m):
	if(parent[i]==-1):
		temp=list(seti[i])
		store=len(temp)
		for j in temp:
			ans[j-1]=store

print(*ans)

for p in range(int(input())):
	arr=list(input())

	n=len(arr)
	for i in range(n):
		arr[i]=ord(arr[i])-96

	arr.sort()

	arr1=arr[:n//2]
	arr2=arr[n//2:]
	arr=[]
	#print(arr,arr1,arr2)
	i1=n//2-1
	i2=n-i1-2

	while (i1!=-1 and i2!=-1):
		arr.append(arr1[i1])
		arr.append(arr2[i2])
		i1-=1
		i2-=1
	if(i1!=-1):
		arr.append(arr1[i1])
	elif(i2!=-1):
		arr.append(arr2[i2])

	s=""
	for i in range(n-1):
		if(abs(arr[i]-arr[i+1])==1):
			s=-1
			print("No answer")
			break
		else:
			s+=chr(arr[i]+96)

	if(s!=-1):
		s+=chr(arr[-1]+96)
		print(s)
#n=0"""

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


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)

# Made By Mostafa_Khaled


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


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


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


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


# -*- coding: utf-8 -*-
"""
Created on Thu Jul 26 20:46:22 2018

@author: chirayu jain
"""
#PROBLEM A FLY
#DIVISION 1 499 CODEFORCES
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)


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
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==0:
    print(temp)
else:
    print("-1")


# -*- coding: utf-8 -*-
"""
Created on Thu Jul 26 20:46:22 2018

@author: chirayu jain
"""

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
res = mass*1.0
print(res)
res = res / (1.0 - 1.0/(1.0*B[0]))
print(res)
for i in range(planet-1,0,-1):
    res = res / (1.0 - 1.0/(A[i]*1.0))
    res = res / (1.0 - 1.0/(B[i]*1.0))
    print(res)
res = res / (1.0 - 1.0/(A[0]*1.0))
res = res - (mass*1.0)
if case==0:
    print(res)
else:
    print("-1")


# -*- coding: utf-8 -*-
"""
Created on Thu Jul 26 20:46:22 2018

@author: chirayu jain
"""
#PROBLEM A FLY
#DIVISION 1 499 CODEFORCES
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
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==0:
    print(temp)
else:
    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=reduce((lambda x,y:x*y),a)
k=k*(reduce((lambda x,y:x*y),b))
a=[int(x)-1 for x in a]
b=[int(x)-1 for x in b]
if 0 in a:
    print(-1)
elif 0 in b:
    print(-1)
else:
    k=k/(reduce((lambda x,y:x*y),a))
    k=k/(reduce((lambda x,y:x*y),b))
    k=k*m
    print(k-m)


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)


 ### @author egaeus
 ### @mail jsbeltran.valhalla@gmail.com
 ### @veredict
 ### @url https://codeforces.com/problemset/problem/1010/A
 ### @category
 ### @date 16/04/2020

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-12:
  p = (b+a) / 2
  if f(arr, p, W):
    b = p
  else:
    a = p

if a <= 1000000000:
  print(a)
else:
  print (-1)


 ### @author egaeus
 ### @mail jsbeltran.valhalla@gmail.com
 ### @veredict
 ### @url https://codeforces.com/problemset/problem/1010/A
 ### @category
 ### @date 16/04/2020

def f(arr, arr1, p, W):
  fuel = p
  for i in range(N):
    expend = (fuel + W) / arr[i]
    fuel -= expend
    expend = (fuel + W) / arr1[(i+1)%N]
    fuel -= expend
    if fuel < 0:
      return False
  return fuel >= 0

N = int(input())
W = int(input())

arr = [0] * N
arr1 = [0] * N

line = input().split()
for i in range(N):
  arr[i] = int(line[i])

line = input().split()
for i in range(N):
  arr1[i] = int(line[i])

a = 0
b = 1000000001

while b - a > 1e-7:
  p = (b+a) / 2
  if f(arr, arr1, p, W):
    b = p
  else:
    a = p

if a <= 1000000000:
  print(a)
else:
  print (-1)


 ### @author egaeus
 ### @mail jsbeltran.valhalla@gmail.com
 ### @veredict
 ### @url https://codeforces.com/problemset/problem/1010/A
 ### @category
 ### @date 16/04/2020

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-7:
  p = (b+a) / 2
  if f(arr, p, W):
    b = p
  else:
    a = p

if a <= 1000000000:
  print(a)
else:
  print (-1)


 ### @author egaeus
 ### @mail jsbeltran.valhalla@gmail.com
 ### @veredict
 ### @url https://codeforces.com/problemset/problem/1010/A
 ### @category
 ### @date 16/04/2020

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


input()
m=int(input())
v=m
try:
 for a in map(int, input().split() + input().split()):
   v*=a
   v/=a-1
 print(v-m)
except ZeroDivisionError:
 print(-1)


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)


input()
m=int(input())
try:
 for a in map(int, input().split() + input().split()):
   m*=a
   m/=a-1
 print(m)
except ZeroDivisionError:
 print(-1)


i=input
i()
m=int(i())
v=m
try:
 for a in map(int, (i()+' '+i()).split()):v*=a/(a-1)
 print(v-m)
except:
 print(-1)


input()
m=int(input())
v=m
try:
 for a in map(int, input().split() + input().split()):
   v*=a/(a-1)
 print(v-m)
except ZeroDivisionError:
 print(-1)


n,m=map(int,input().split())
for a in map(int, input().split() + input().split()):
   m*=a
   m/=a-1
print(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.)
        print(x - m)
    except ZeroDivisionError:
        print(-1)

if __name__ == '__main__':
    main()


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)


import sys

if __name__ == '__main__':
	n = int(sys.stdin.readline().strip())
	m = int(sys.stdin.readline().strip())
	eps = 2e-7
	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
		#print (10/3)
		def is_ok(target):
			total = m + target
			remain = total
			for i in range(n):
				remain -= remain/off[i]
				#print (remain)
				if remain < m and abs(remain - m) > eps:
					return False
				remain -= remain / land[(i+1)%n]
				#print (remain)
				if remain < m and abs(remain - m) > eps:
					return False
			return True
		#is_ok(6)
		while True:
			mid = (l + r) / 2
			if abs(r-l) <= eps:
				print (mid)
				break
			if is_ok(mid):
				r = mid
			else:
				l = mid


import sys

if __name__ == '__main__':
	n = int(sys.stdin.readline().strip())
	m = int(sys.stdin.readline().strip())
	eps = 2e-7
	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
		#print (10/3)
		def is_ok(target):
			total = m + target
			remain = total
			for i in range(n):
				remain -= remain/off[i]
				#print (remain)
				if remain < m and abs(remain - m) > eps:
					return False
				remain -= remain / land[(i+1)%n]
				#print (remain)
				if remain < m and abs(remain - m) > eps:
					return False
			return True
		#is_ok(6)
		while True:
			mid = (l + r) / 2
			if abs(r-l) <= eps:
				print (mid)
				break
			if is_ok(mid):
				r = mid
			else:
				l = mid + 1


def main():
    n = int(raw_input())
    m = int(raw_input())
    a = map(int, raw_input().split())
    b = map(int, raw_input().split())
    a += b
    if 1 in a:
        print -1
        return
    t = 1. * m
    for x in a:
        t = t * x / (x - 1)
        if t > 1e20:
            print -1
            return
    print "%.12f" % (t - m)
main()


import os,sys
n=int(raw_input())
m=int(raw_input())
a=map(int,raw_input().split(' '))
b=map(int,raw_input().split(' '))
t=0
for i in range(0,n)[::-1]:
    x=b[(i+1)%n]
    if x==1:
        print '-1'
        sys.exit(0)
    t=(t*1.0*x+m)/(x-1)
    x=a[i]
    if x==1:
        print '-1'
        sys.exit(0)
    t=(t*1.0*x+m)/(x-1)
print '%.10lf'%t


n=[int(k) for k in raw_input().split(" ")][0]
m=[int(k) for k in raw_input().split(" ")][0]
a=[float(k) for k in raw_input().split(" ")]
b=[float(k) for k in raw_input().split(" ")]

eps=10**-7

def cando(f):
    for i in range(n):
        w=f+m
        wto=w/a[i]
        f-=wto
        if f<-eps:
            return False
        w=f+m
        wto=w/b[(i+1)%n]
        f-=wto
        if f<-eps:
            return False
    return True

f=0
ta=10**9

if not cando(ta):
    print -1
else:
    while ta>=max(eps, eps*f):
        if not cando(f+ta):
            f+=ta
        ta/=2.

    print "{:.7f}".format(f + ta*2)


n=[int(k) for k in raw_input().split(" ")][0]
m=[int(k) for k in raw_input().split(" ")][0]
a=[float(k) for k in raw_input().split(" ")]
b=[float(k) for k in raw_input().split(" ")]

def cando(f):
    for i in range(n):
        w=f+m
        wto=w/a[i]
        f-=wto
        if f<0:
            return False
        w=f+m
        wto=w/b[(i+1)%n]
        f-=wto
        if f<0:
            return False
    return True

eps=10**-7

f=0
ta=10**9

if not cando(ta):
    print -1
else:
    while ta>=max(eps, eps*f):
        if not cando(f+ta):
            f+=ta
        ta/=2.

    print "{:.7f}".format(f + ta*2)


# coding: utf-8

n = int(raw_input())
m = int(raw_input())
A = map(int, raw_input().split(' '))
B = map(int, raw_input().split(' '))

M = float(m)
for i in range(n):
    if B[i] == 1 or A[n-i-1] == 1:
        M = -1
        break
    M = M/(B[i]-1)+M
    M = M/(A[n-i-1]-1)+M
else:
    M -= m
print M


#include <stdio.h>

int main ()
{
	int n, m, i;
	double c = 1.0, x;
	scanf ("%d%d", &n, &m);
	for (i = 0; i < n * 2; i++)
	{
		scanf ("%lf", &x);
		c *= 1 - 1 / x;
	}
	printf ("%.10f\n", c > 0 ? m / c - m : -1);
	return 0;
}


#include <stdio.h>

int main ()
{
	int n, m, i;
	double c = 1.0, x;
	scanf ("%d%d", &n, &m);
	for (i = 0; i < n * 2; i++)
	{
		scanf ("%f", &x);
		c *= 1 - 1 / x;
	}
	printf ("%.10f\n", c > 0 ? m / c - m : -1);
	return 0;
}


#include <stdio.h>

int main ()
{
	int n, m, i;
	double c = 1.0, x;
	scanf ("%d%d", &n, &m);
	for (i = 0; i < n * 2; i++)
	{
		scanf ("%lf", &x);
		c *= 1 - 1 / x;
	}
	printf ("%.10lf\n", c > 0 ? m / c - m : -1);
	return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here
	long int n,m;
	scanf("%ld %ld",&n,&m);
	long int a[n];
	long int b[n];
	for (int i=0;i<n;i++){
	    scanf("%ld",&a[i]);
        if (a[i]==1){
            printf("-1");
            return 0;
        }
	}
	for (int i=0;i<n;i++){
	    scanf("%ld",&b[i]);
        if (b[i]==1){
            printf("-1");
            return 0;
        }
	}
	long int an = 0;
	long int bn = 1;
	long int ab[2*n];
	for (int i=0;i<2*n;i++){
	    if (i%2==0){
	        ab[i] = a[an++];
	    }
	    else{
	        if (bn==n){
	            ab[i] = b[0];
	        }
	        else{
	            ab[i] = b[bn++];
	        }
	    }
	}
	double result = (double)m;
	for (int i=((2*n)-1);i>=0;i--){
	    double result1 = (double)result / ((double)ab[i] - 1);
	    result += result1;
	}
	result -= (double)m;
	printf("%f\n",result);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    float f,dumbv=1.0;
    int nump,i,rocw8;
    scanf("%d ",&nump);
    scanf("%d ",&rocw8);

    int tol[2*nump];
    for(i=0;i<2*nump;i++)
    {
        scanf("%d",&tol[i]);
    }

    for(i=0;i<2*nump;i++)
    {
        dumbv=1.0*dumbv*(tol[i]-1)/tol[i];
    }
    if(!dumbv){
        printf("-1");
        exit(0);
    }

    dumbv=(rocw8*1.0)/dumbv;
    dumbv=dumbv-(rocw8*1.0);
    printf("%.10f",dumbv);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    double f,dumbv=1.0;
    int nump,i,rocw8;
    scanf("%d ",&nump);
    scanf("%d ",&rocw8);

    int tol[2*nump];
    for(i=0;i<2*nump;i++)
    {
        scanf("%d",&tol[i]);
    }

    for(i=0;i<2*nump;i++)
    {
        dumbv=1.0*dumbv*(tol[i]-1)/tol[i];
    }
    if(!dumbv){
        printf("-1");
        exit(0);
    }

    dumbv=(rocw8*1.0)/dumbv;
    dumbv=dumbv-(rocw8*1.0);
    printf("%.10lf",dumbv);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
        double f,dumbv=1;
    int nump,i,rocw8;
    scanf("%d ",&nump);
    scanf("%d ",&rocw8);

    int tol[2*nump];
    for(i=0;i<2*nump;i++)
    {
        scanf("%d",&tol[i]);
    }

    for(i=0;i<2*nump;i++)
    {
        dumbv=dumbv*(tol[i]-1)/tol[i];
    }
    if(!dumbv){
        printf("-1");
        exit(0);
    }

    dumbv=(rocw8)/dumbv;
    dumbv=dumbv-rocw8;
    printf("%.10f",dumbv);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    double f,dumbv=1.0;
    int nump,i,rocw8;
    scanf("%d ",&nump);
    scanf("%d ",&rocw8);

    int tol[2*nump];
    for(i=0;i<2*nump;i++)
    {
        scanf("%d",&tol[i]);
    }

    for(i=0;i<2*nump;i++)
    {
        dumbv=dumbv*(tol[i]-1)/tol[i];
    }
    if(!dumbv){
        printf("-1");
        exit(0);
    }

    dumbv=rocw8/dumbv;
    dumbv=dumbv-rocw8;
    printf("%.10lf",dumbv);
    return 0;
}


using System;
using System.Linq;

namespace CSharp
{
    class _1010A
    {
        private const double MaxFuel = 1e9;

        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            double m = double.Parse(Console.ReadLine());
            double[] a = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();
            double[] b = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();

            double l = 0;
            double r = 2 * MaxFuel;

            while (r - l > 1e-7 && l <= MaxFuel)
            {
                double fuel = (r + l) / 2;
                double weight = m + fuel;

                for (int i = 0; i < n && weight >= m; i++)
                {
                    weight -= weight / a[i];
                    weight -= weight / b[(i + 1) % n];
                }

                if (weight >= m)
                {
                    r = fuel;
                }
                else
                {
                    l = fuel;
                }
            }

            Console.WriteLine(r > MaxFuel ? -1 : r);
        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    class _1010A
    {
        private const double MaxFuel = 1e9;

        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            double m = double.Parse(Console.ReadLine());
            double[] a = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();
            double[] b = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();

            double l = 0;
            double r = 2 * MaxFuel;

            while (r - l > 1e-7)
            {
                double fuel = (r + l) / 2;
                double weight = m + fuel;

                for (int i = 0; i < n && weight >= m; i++)
                {
                    weight -= weight / a[i];
                    weight -= weight / b[(i + 1) % n];
                }

                if (weight >= m)
                {
                    r = fuel;
                }
                else
                {
                    l = fuel;
                }
            }

            Console.WriteLine(r > MaxFuel ? -1 : r);
        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    class _1010A
    {
        private const double MaxFuel = 1e9;

        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            double m = double.Parse(Console.ReadLine());
            double[] a = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();
            double[] b = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();

            double l = 0;
            double r = 2 * MaxFuel;

            while (r - l > 1e-7)
            {
                double fuel = (r + l) / 2;
                double weight = m + fuel;

                for (int i = 0; i < n; i++)
                {
                    weight -= weight / a[i];
                    weight -= weight / b[(i + 1) % n];
                }

                if (weight >= m)
                {
                    r = fuel;
                }
                else
                {
                    l = fuel;
                }
            }

            Console.WriteLine(r > MaxFuel ? -1 : r);
        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    class _1010A
    {
        private const double MaxFuel = 1e9;

        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            double m = double.Parse(Console.ReadLine());
            double[] a = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();
            double[] b = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();

            double l = 0;
            double r = 2 * MaxFuel;

            while (r - l > r * 1e-6 && l <= MaxFuel)
            {
                double fuel = (r + l) / 2;
                double weight = m + fuel;

                for (int i = 0; i < n && weight >= m; i++)
                {
                    weight -= weight / a[i];
                    weight -= weight / b[(i + 1) % n];
                }

                if (weight >= m)
                {
                    r = fuel;
                }
                else
                {
                    l = fuel;
                }
            }

            Console.WriteLine(r > MaxFuel ? -1 : r);
        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    class _1010A
    {
        private const double MaxFuel = 1e9;

        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            double m = double.Parse(Console.ReadLine());
            double[] a = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();
            double[] b = Console.ReadLine().Split().Select(token => double.Parse(token)).ToArray();

            double l = 0;
            double r = 2 * MaxFuel;

            while (r - l > r * 1e-6 && l <= MaxFuel + double.Epsilon)
            {
                double fuel = (r + l) / 2;
                double weight = m + fuel;

                for (int i = 0; i < n && weight >= m; i++)
                {
                    weight -= weight / a[i];
                    weight -= weight / b[(i + 1) % n];
                }

                if (weight >= m)
                {
                    r = fuel;
                }
                else
                {
                    l = fuel;
                }
            }

            Console.WriteLine(l > MaxFuel + double.Epsilon ? -1 : l);
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Text;

namespace Fly
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            Solve(args);
            writer.Flush();
        }

        private static void Solve(string[] args)
        {
            int n = Next();
            int v = Next();

            var a = new int[n + 1];
            var b = new int[n + 1];
            for (int i = 0; i < n; i++)
            {
                a[i] = Next();
                b[i] = Next();
            }
            a[n] = a[0];
            b[n] = b[0];

            double l = 0, r = 1000000001;
            for (int ii = 0; ii < 128; ii++)
            {
                double m = (l + r)/2;
                bool e = true;

                double p = v + m;

                for (int i = 1; i < a.Length; i++)
                {
                    p -= p/a[i - 1];
                    if (p < v)
                    {
                        e = false;
                        break;
                    }
                    p -= p/b[i - 1];
                    if (p < v)
                    {
                        e = false;
                        break;
                    }
                }

                if (e)
                    r = m;
                else
                    l = m;
            }
            if (l > 1000000000.01)
            {
                writer.WriteLine("-1");
                return;
            }
            writer.WriteLine(l.ToString("#0.0000000", CultureInfo.InvariantCulture));
            ;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::BTreeSet;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::HashSet;
use std::fmt::Display;
use std::fs::File;
use std::io::Read;
#[allow(unused_imports)]
use std::mem;

#[allow(dead_code)]
fn pow_speedy_with_mod(mut p: i64, mut q: i64, m: i64) -> i64 {
    p %= m;
    let mut r = p;
    let mut ret: i64 = 1;
    while q > 0 {
        ret *= if q % 2 == 1 { r } else { 1 };
        r *= r;
        r %= m;
        q /= 2;
        ret %= m;
    }
    return ret;
}

#[allow(dead_code)]
fn comb(n: usize, k: usize, m: i64, frac: &[i64], frac_inv: &[i64]) -> i64 {
    let mut ret = 1i64;
    if n < k {
        return 0;
    }
    ret *= frac[n] * frac_inv[n - k];
    ret %= m;
    ret *= frac_inv[k];
    ret %= m;
    ret
}

#[allow(dead_code)]
fn show1dvec<T: Display>(v: &Vec<T>) {
    let n = v.len();
    for i in 0..n - 1 {
        print!("{} ", v[i]);
    }
    println!("{} ", v[n - 1]);
}

#[allow(dead_code)]
fn check(i: usize, j: usize, h: usize, w: usize) -> bool {
    i < h && j < w
}

#[derive(Debug)]
struct Piece {
    mark: char,
    y: i32,
    x: i32,
}

fn main() {
    let inputstatus = 1;

    let mut buf = String::new();
    let filename = "inputrust.txt";

    if inputstatus == 0 {
        let mut f = File::open(filename).expect("file not found");
        f.read_to_string(&mut buf)
            .expect("something went wrong reading the file");
    } else {
        std::io::stdin().read_to_string(&mut buf).unwrap();
    }

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: f64 = iter.next().unwrap().parse().unwrap();
    let mut v = vec![0f64; 2 * n];
    for i in 0..n {
        let a: f64 = iter.next().unwrap().parse().unwrap();
        v[2 * i] = a;
    }
    for i in 0..n {
        let a: f64 = iter.next().unwrap().parse().unwrap();
        v[(2 * i + 2 * n - 1) % (2 * n)] = a;
    }

    let mut ok = 1e9 + 1f64;
    let mut ng = 0f64;
    let mut mid: f64;
    for i in 0..1000 {
        mid = (ok + ng) / 2f64;
        if total_consume(n, mid, m, &v) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    println!("{}", if ok > 1e9 {-1f64} else {ok});

    // let n = iter.next().unwrap().parse().unwrap();

    // println!("{}", n);
    // println!("{:?}", cum_num);
}

fn total_consume(n: usize, f: f64, m: f64, v: &Vec<f64>) -> bool {
    let mut ret = true;
    let mut x = f + m;
    for i in 0..2 * n {
        x = x - x / v[i];
        if x < m {
            ret = false;
            break;
        }
    }
    ret
}


#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::BTreeSet;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::HashSet;
use std::fmt::Display;
use std::fs::File;
use std::io::Read;
#[allow(unused_imports)]
use std::mem;

#[allow(dead_code)]
fn pow_speedy_with_mod(mut p: i64, mut q: i64, m: i64) -> i64 {
    p %= m;
    let mut r = p;
    let mut ret: i64 = 1;
    while q > 0 {
        ret *= if q % 2 == 1 { r } else { 1 };
        r *= r;
        r %= m;
        q /= 2;
        ret %= m;
    }
    return ret;
}

#[allow(dead_code)]
fn comb(n: usize, k: usize, m: i64, frac: &[i64], frac_inv: &[i64]) -> i64 {
    let mut ret = 1i64;
    if n < k {
        return 0;
    }
    ret *= frac[n] * frac_inv[n - k];
    ret %= m;
    ret *= frac_inv[k];
    ret %= m;
    ret
}

#[allow(dead_code)]
fn show1dvec<T: Display>(v: &Vec<T>) {
    let n = v.len();
    for i in 0..n - 1 {
        print!("{} ", v[i]);
    }
    println!("{} ", v[n - 1]);
}

#[allow(dead_code)]
fn check(i: usize, j: usize, h: usize, w: usize) -> bool {
    i < h && j < w
}

#[derive(Debug)]
struct Piece {
    mark: char,
    y: i32,
    x: i32,
}

fn main() {
    let inputstatus = 1;

    let mut buf = String::new();
    let filename = "inputrust.txt";

    if inputstatus == 0 {
        let mut f = File::open(filename).expect("file not found");
        f.read_to_string(&mut buf)
            .expect("something went wrong reading the file");
    } else {
        std::io::stdin().read_to_string(&mut buf).unwrap();
    }

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: f64 = iter.next().unwrap().parse().unwrap();
    let mut v = vec![0f64; 2 * n];
    for i in 0..n {
        let a: f64 = iter.next().unwrap().parse().unwrap();
        v[2 * i] = a;
    }
    for i in 0..n {
        let a: f64 = iter.next().unwrap().parse().unwrap();
        v[(2 * i + 2 * n - 1) % (2 * n)] = a;
    }

    let mut ok = 1e9 + 1f64;
    let mut ng = 0f64;
    let mut mid: f64;
    for i in 0..1000 {
        mid = (ok + ng) / 2f64;
        if total_consume(n, mid, m, &v) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    println!("{}", if ok > 1e9 + 0.1f64 {-1f64} else {ok});

    // let n = iter.next().unwrap().parse().unwrap();

    // println!("{}", n);
    // println!("{:?}", cum_num);
}

fn total_consume(n: usize, f: f64, m: f64, v: &Vec<f64>) -> bool {
    let mut ret = true;
    let mut x = f + m;
    for i in 0..2 * n {
        x = x - x / v[i];
        if x < m {
            ret = false;
            break;
        }
    }
    ret
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%d\n", &m)
	initWeight := float64(m)
	weight := initWeight
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		a[i] = t
	}
	fmt.Fscanf(in, "\n")
	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		b[i] = t
	}
	for i := 0; i < n; i++ {
		if a[i] == 1 || b[i] == 1 {
			fmt.Fprintf(out, "-1\n")
			return
		}
	}
	q1 := n - 1
	q2 := 0
	for i := 0; i < 2*n; i++ {
		var sp float64
		if i%2 == 0 {
			sp = float64(b[q2])
			if q2 == 0 {
				q2 = n - 1
			} else {
				q2--
			}
		} else {
			sp = float64(a[q1])
			q1--
		}
		weight = weight + weight/(sp-1.0)
	}
	fmt.Fprintf(out, "%.9f\n", weight-initWeight)
	return
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%d\n", &m)
	initWeight := float64(m)
	weight := initWeight
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	fmt.Fscanf(in, "\n")
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &b[i])
	}
	for i := 0; i < n; i++ {
		if a[i] == 1 || b[i] == 1 {
			fmt.Fprintf(out, "-1\n")
			return
		}
	}
	q1 := n - 1
	q2 := 0
	for i := 0; i < 2*n; i++ {
		var sp float64
		if i%2 == 0 {
			sp = float64(b[q2])
			if q2 == 0 {
				q2 = n - 1
			} else {
				q2--
			}
		} else {
			sp = float64(a[q1])
			q1--
		}
		weight = weight + weight/(sp-1.0)
	}
	fmt.Fprintf(out, "%.9f\n", weight-initWeight)
	return
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%d\n", &m)
	weight := float64(0)
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	fmt.Fscanf(in, "\n")
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &b[i])
	}
	for i := 0; i < n; i++ {
		if a[i] == 1 || b[i] == 1 {
			fmt.Fprintf(out, "-1\n")
			return
		}
	}
	q1 := n - 1
	q2 := 0
	for i := 0; i < 2*n; i++ {
		var sp float64
		if i%2 == 0 {
			sp = float64(b[q2])
			if q2 == 0 {
				q2 = n - 1
			} else {
				q2--
			}
		} else {
			sp = float64(a[q1])
			q1--
		}
		weight = weight + weight/(sp-1.0)
	}
	fmt.Fprintf(out, "%.9f\n", weight)
	return
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%d\n", &m)
	initWeight := float64(m)
	weight := initWeight
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		a[i] = t
	}
	fmt.Fscanf(in, "\n")

	for i := 0; i < n; i++ {
		t := 0
		fmt.Fscanf(in, "%d", &t)
		b[i] = t
	}
	q1 := n - 1
	q2 := 0
	noAnswer := false
	for i := 0; i < 2*n; i++ {
		sp := 0.0
		if i%2 == 0 {
			if b[q2] == 1 {
				noAnswer = true
				break
			}
			sp = float64(b[q2])
			if q2 == 0 {
				q2 = n - 1
			} else {
				q2--
			}
		} else {
			if a[q1] == 1 {
				noAnswer = true
				break
			}
			sp = float64(a[q1])
			q1--
		}
		weight = weight + weight/(sp-1.0)
	}
	if noAnswer {
		fmt.Fprintf(out, "-1\n")
	} else {
		fmt.Fprintf(out, "%.9f\n", weight-initWeight)
	}
	return
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func valiate(tar float64, a int, b []int) bool {
	for i := 0; i < len(b); i++ {
		cost := (tar + float64(a)) / float64(b[i])
		tar -= cost
		if tar < 0 {
			return false
		}
	}
	return true
}

func solve(a int, b []int) float64 {
	l, r, best, count := 0.0, 2e9, -1.0, 2000
	for l <= r && count > 0 {
		mid := (l + r) / 2
		count = count - 1
		// Works, means there is enough fuel
		if valiate(mid, a, b) {
			r, best = mid, mid
		} else {
			l = mid
		}
	}
	return best
}

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, a := scanNum(), scanNum()
	b := make([]int, n*2)
	for i := 0; i < n; i++ {
		b[i*2] = scanNum()
	}
	b[n*2-1] = scanNum()
	for i := 0; i < n-1; i++ {
		b[i*2+1] = scanNum()
	}

	res := solve(a, b)
	if res < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(res)
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func valiate(tar float64, a int, b []int) bool {
	for i := 0; i < len(b); i++ {
		cost := (tar + float64(a)) / float64(b[i])
		tar -= cost
		if tar < 0 {
			return false
		}
	}
	return true
}

func solve(a int, b []int) float64 {
	l, r, best, count := 0.0, 1e9, -1.0, 1000
	for l <= r && count > 0 {
		mid := (l + r) / 2
		count = count - 1
		// Works, means there is enough fuel
		if valiate(mid, a, b) {
			r, best = mid, mid
		} else {
			l = mid
		}
	}
	return best
}

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, a := scanNum(), scanNum()
	b := make([]int, n*2)
	for i := 0; i < n; i++ {
		b[i*2] = scanNum()
	}
	b[n*2-1] = scanNum()
	for i := 0; i < n-1; i++ {
		b[i*2+1] = scanNum()
	}

	res := solve(a, b)
	if res < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(res)
	}
}


import sys
def poss(fuel, payload, ai, bi):
    fuel-=(fuel+payload)/ai[0]
    if fuel<0:
        return False
    for i in range(n):
        fuel-=(fuel+payload)/bi[i]
        if fuel<0:
            return False
        fuel-=(fuel+payload)/ai[i]
        if fuel<0:
            return False
    fuel-=(fuel+payload)/bi[0]
    if fuel<0:
        return False
    return True

n=int(raw_input())
m=float(raw_input())
a=map(float, raw_input().split())
b=map(float, raw_input().split())

if 1 in a or 1 in b:
    print -1
    sys.exit(0)

fuel=0.0
fuel=m/(b[0]-1)
for i in range(n-1,0,-1):
    fuel=(fuel*a[i]+m)/(a[i]-1)
    fuel=(fuel*b[i]+m)/(b[i]-1)
fuel=(fuel*a[0]+m)/(a[0]-1)
print fuel


n=int(raw_input())
# IN, AND, OR, XOR, NOT

flw=[None for i in range(n)]
prv=[None for i in range(n)]
inval={}
typ=[None for i in range(n)]
inidx=[]

for i in range(n):
    args=raw_input().split()
    if args[0]=='IN':
        if args[1]=='0':
            inval[i]=False
        else:
            inval[i]=True
        typ[i]=0
        inidx.append(i)
    elif args[0]=='AND':
        i1, i2=int(args[1])-1, int(args[2])-1
        prv[i]=(i1,i2)
        flw[i1]=i
        flw[i2]=i
        typ[i]=1
    elif args[0]=='OR':
        i1, i2=int(args[1])-1, int(args[2])-1
        prv[i]=(i1,i2)
        flw[i1]=i
        flw[i2]=i
        typ[i]=2
    elif args[0]=='XOR':
        i1, i2=int(args[1])-1, int(args[2])-1
        prv[i]=(i1,i2)
        flw[i1]=i
        flw[i2]=i
        typ[i]=3
    elif args[0]=='NOT':
        i1=int(args[1])-1
        prv[i]=(i1,)
        flw[i1]=i
        typ[i]=4
    else:
        assert False

toposort=[]
visited=set()
for innode in inidx:
    csort=[]
    curnode=innode
    while curnode not in visited:
        csort.append(curnode)
        visited.add(curnode)
        if curnode==0: break
        curnode=flw[curnode]
    toposort.extend(csort[::-1])

value=[False for i in range(n)]
# IN, AND, OR, XOR, NOT
for i in toposort[::-1]:
    if typ[i]==0:
        value[i]=inval[i]
    elif typ[i]==1:
        value[i]=value[prv[i][0]] and value[prv[i][1]]
    elif typ[i]==2:
        value[i]=value[prv[i][0]] or value[prv[i][1]]
    elif typ[i]==3:
        value[i]=value[prv[i][0]] ^ value[prv[i][1]]
    elif typ[i]==4:
        value[i]=not value[prv[i][0]]

canchange=[False for i in range(n)]
canchange[0]=True
for i in toposort:
    if not canchange[i]:
        continue
    if typ[i]==0:
        continue
    elif typ[i]==1:
        if value[prv[i][0]] and value[prv[i][1]]:
            canchange[prv[i][0]]=True
            canchange[prv[i][1]]=True
        elif value[prv[i][0]]:
            canchange[prv[i][1]]=True
        elif value[prv[i][1]]:
            canchange[prv[i][0]]=True

    elif typ[i]==2:
        if not value[prv[i][0]] and not value[prv[i][1]]:
            canchange[prv[i][0]]=True
            canchange[prv[i][1]]=True
        elif value[prv[i][0]] and value[prv[i][1]]:
            pass
        elif value[prv[i][0]]:
            canchange[prv[i][0]]=True
        elif value[prv[i][1]]:
            canchange[prv[i][1]]=True

    elif typ[i]==3:
        canchange[prv[i][0]]=True
        canchange[prv[i][1]]=True

    elif typ[i]==4:
        canchange[prv[i][0]]=True

res=''
for e in inidx:
    if value[0] ^ canchange[e]:
        res+='1'
    else:
        res+='0'

print res


import sys
def poss(fuel, payload, ai, bi):
    fuel-=(fuel+payload)/ai[0]
    if fuel<0:
        return False
    for i in range(n):
        fuel-=(fuel+payload)/bi[i]
        if fuel<0:
            return False
        fuel-=(fuel+payload)/ai[i]
        if fuel<0:
            return False
    fuel-=(fuel+payload)/bi[0]
    if fuel<0:
        return False
    return True

n=int(raw_input())
m=float(raw_input())
a=map(float, raw_input().split())
b=map(float, raw_input().split())

if 1 in a or 1 in b:
    print -1
    sys.exit(0)

fuel=0.0
fuel=m/(b[0]-1)
for i in range(n-1,0,-1):
    fuel=(fuel*a[i]+m)/(a[i]-1)
    fuel=(fuel*b[i]+m)/(b[i]-1)
fuel=(fuel*a[0]+m)/(a[0]-1)
print fuel if fuel<=1e9 else -1


import sys
def poss(fuel, payload, ai, bi):
    fuel-=(fuel+payload)/ai[0]
    if fuel<0:
        return False
    for i in range(n):
        fuel-=(fuel+payload)/bi[i]
        if fuel<0:
            return False
        fuel-=(fuel+payload)/ai[i]
        if fuel<0:
            return False
    fuel-=(fuel+payload)/bi[0]
    if fuel<0:
        return False
    return True

n=int(raw_input())
m=float(raw_input())
a=map(float, raw_input().split())
b=map(float, raw_input().split())

if 1 in a or 1 in b:
    print -1
    sys.exit(0)

fuel=0.0
fuel=m/(b[0]-1)
for i in range(n-1,0,-1):
    fuel=(fuel*a[i]+m)/(a[i]-1)
    fuel=(fuel*b[i]+m)/(b[i]-1)
fuel=(fuel*a[0]+m)/(a[0]-1)
print fuel if fuel<1e9 else -1


n=input()
m=float(raw_input())
a=[]
a.append(map(float,raw_input().split()))
a.append(map(float,raw_input().split()))
x=m
if a[1][0]==1:
    print -1
    exit(0)
x+=x/(a[1][0]-1)
i=0
j=n-1
while i!=1 or j!=0:
    if a[i][j]==1:
        print -1
        exit(0)
    x+=x/(a[i][j]-1)
    #print i,j,x
    if i==0:
        i+=1
    else:
        i=0
        j-=1
    #print i,j
print x-m


from __future__ import print_function, division
import sys

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

def ok(f):
    f += m
    for i in xrange(n):
        g = (i + 1) % n
        t = f / a[i]
        f -= t
        if f < m:
            return False
        t = f / b[g]
        f -= t
        if f < m:
            return False
    return True

l, r = 0, 10**10
for i in xrange(100):
    mid = (l + r) / 2
    if ok(mid):
        r = mid
    else:
        l = mid
if not ok(r):
    print(-1)
else:
    print("{:.08f}".format(l))


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


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)


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=1000000003
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


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=1000000001
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


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-0.000001
        else:
            l=mid+0.000001

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


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=1000000002
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


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
    r=10**9
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


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=1000000004
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


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
    r=10**9+1
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


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=1000000007
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


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=1000000005
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


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=10**9
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


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=10**9+1
    ans=-1
    while r>=l:
        mid=round((r+l)/2,6)
        if issuff(n,m,a,b,mid):
            ans=mid
            r=mid-0.000001
        else:
            l=mid+0.000001

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


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l, r = 0, 10 ** 10
e = 10 ** -7
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(2, 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
print(r)


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().split()))
b = list(map(int, input().split()))
l, r = 0, 10 ** 10
e = 10 ** -7
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 > 2 * 10 ** 9:
    print(-1)
else:
    print(r)


#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5 + 5;
const int INF = 1e18;
int a[N];

main()
{
    int n, m, t;
    cin >> t;
    while (t --){
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> a[i];
    while (true)
    {
        bool ch = 0;
        for (int i = 1; i <= n; i ++)
        {
            for (int j = i + 1; j <= n; j ++)
            {
                if (i - a[i] == j - a[j]){ch = 1; break;}
            }
        }
        if (ch == 0)break;
        random_shuffle(a + 1, a + n + 1);
    }
    for (int i = 1; i <= n; i ++)cout << a[i] << ' ';
    cout << '\n';
    }
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5 + 5;
//const int INF = 1e18;
int a[N];

main()
{
    int n, m, t;
    cin >> t;
    while (t --){
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> a[i];
    while (true)
    {
        bool ch = 0;
        for (int i = 1; i <= n; i ++)
        {
            for (int j = i + 1; j < n; j ++)
            {
                if (i - a[i] == j - a[j]){ch = 1; break;}
            }
        }
        if (ch == 0)break;
        random_shuffle(a + 1, a + n + 1);
    }
    for (int i = 1; i <= n; i ++)cout << a[i] << ' ';
    cout << '\n';
    }
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5 + 5;
const int INF = 1e18;
int a[N];

main()
{
    int n, m, t;
    cin >> t;
    while (t --){
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> a[i];
    while (true)
    {
        bool ch = 0;
        for (int i = 1; i <= n; i ++)
        {
            for (int j = i + 1; j <= n; j ++)
            {
                if (i - a[i] == j - a[j]){ch = 1; swap(a[i], a[j]); break;}
            }
        }
        if (ch == 0)break;
    }
    for (int i = 1; i <= n; i ++)cout << a[i] << ' ';
    cout << '\n';
    }
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5 + 5;
const int INF = 1e18;
int a[N];

main()
{
    int n, m, t;
    cin >> t;
    while (t --){
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> a[i];
    while (true)
    {
        bool ch = 0;
        for (int i = 1; i <= n; i ++)
        {
            for (int j = i + 1; j < n; j ++)
            {
                if (i - a[i] == j - a[j]){ch = 1; break;}
            }
        }
        if (ch == 0)break;
        random_shuffle(a + 1, a + n + 1);
    }
    for (int i = 1; i <= n; i ++)cout << a[i] << ' ';
    cout << '\n';
    }
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5 + 5;
//const int INF = 1e18;
int a[N];

main()
{
    int n, m, t;
    cin >> t;
    while (t --){
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> a[i];
    while (true)
    {
        bool ch = 0;
        for (int i = 1; i <= n; i ++)
        {
            for (int j = i + 1; j <= n; j ++)
            {
                if (i - a[i] == j - a[j]){ch = 1; break;}
            }
        }
        if (ch == 0)break;
        random_shuffle(a + 1, a + n + 1);
    }
    for (int i = 1; i <= n; i ++)cout << a[i] << ' ';
    cout << '\n';
    }
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <conio.h>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)

using namespace std;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

bool check(vector<int> & vec) {
	for (int i = 0; i < vec.size(); i++) {
		for (int j = i + 1; j < vec.size(); j++) {
			if (j - vec[j] == i - vec[i]) {
				return false;
			}
		}
	}

	return true;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> vec(n);
		for (int i = 0; i < vec.size(); i++) {
			cin >> vec[i];
		}

		while (!check(vec)) {
			for (int i = 0; i < vec.size(); i++) {
				for (int j = i + 1; j < vec.size(); j++) {
					if (j - vec[j] == i - vec[i]) {
						for (int k = 0; k < vec.size(); k++) {
							if (k - vec[k] != i - vec[i]) {
								swap(vec[j], vec[k]);
								break;
							}
						}
					}
				}
			}
		}

		for (int i = 0; i < vec.size(); i++) {
			cout << vec[i] << ' ';
		}
		cout << endl;
	}

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <conio.h>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)

using namespace std;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

bool check(vector<int> & vec) {
	for (int i = 0; i < vec.size(); i++) {
		for (int j = i + 1; j < vec.size(); j++) {
			if (j - vec[j] == i - vec[i]) {
				return false;
			}
		}
	}

	return true;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> vec(n);
		for (int i = 0; i < vec.size(); i++) {
			cin >> vec[i];
		}

		while (n--) {
			for (int i = 0; i < vec.size(); i++) {
				for (int j = i + 1; j < vec.size(); j++) {
					if (j - vec[j] == i - vec[i]) {
						for (int k = 0; k < vec.size(); k++) {
							if (k - vec[k] != i - vec[i]) {
								swap(vec[j], vec[k]);
								break;
							}
						}
					}
				}
			}
		}

		for (int i = 0; i < vec.size(); i++) {
			cout << vec[i] << ' ';
		}
		cout << endl;
	}

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <conio.h>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)

using namespace std;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> vec(n);
		for (int i = 0; i < vec.size(); i++) {
			cin >> vec[i];
		}

		for (int i = 0; i < vec.size(); i++) {
			for (int j = i + 1; j < vec.size(); j++) {
				if (j - vec[j] == i - vec[i]) {
					for (int k = i + 2; k < vec.size(); k++) {
						if (k - vec[k] != i - vec[i]) {
							swap(vec[j], vec[k]);
							break;
						}
					}
				}
			}
		}

		for (int i = 0; i < vec.size(); i++) {
			cout << vec[i] << ' ';
		}
		cout << endl;
	}

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <conio.h>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)

using namespace std;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> vec(n);
		for (int i = 0; i < vec.size(); i++) {
			cin >> vec[i];
		}

		sort(rall(vec));
		for (int i = 0; i < vec.size(); i++) {
			cout << vec[i] << ' ';
		}
		cout << endl;
	}

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <conio.h>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)

using namespace std;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

bool check(vector<int> & vec) {
	for (int i = 0; i < vec.size(); i++) {
		for (int j = i + 1; j < vec.size(); j++) {
			if (j - vec[j] == i - vec[i]) {
				return false;
			}
		}
	}

	return true;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> vec(n);
		for (int i = 0; i < vec.size(); i++) {
			cin >> vec[i];
		}

		sort(rall(vec));
		for (int i = 0; i < vec.size(); i++) {
			cout << vec[i] << ' ';
		}
		cout << endl;
	}

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void bogsort()
{
	struct {
		bool operator()(int a, int b) {
			return a > b;

		}
	}pp;
	int t, n;
	cin >> t;

	while (t--)
	{
		cin >> n;
		vector<int>a;
		for (int i = 0; i < n; i++)
		{
			int k;
			cin >> k;
			a.push_back(k);
		}
		sort(a.begin(), a.end(), pp);

		for (int i = 0; i < n; i++)
			cout << a[i] << " ";
		cout << endl;
	}
}

int main()
{
	bogsort();
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct {
	bool operator()(pair<int,int> &b, pair<int,int> &c) {
		if (b.first - c.second < c.first - b.second)
		{
			swap(b.second, c.second);
			return true;
		}
		return false;

	}
}pp;
int main()
{
	int t,n;
	cin >> t;
	while (t--)
	{
		cin >> n;
		vector<pair<int,int>>tmp;
		for (int i = 0; i < n; i++)
		{
			int k;
			cin >> k;
			tmp.push_back(pair<int,int>(k,i));

		}
		sort(tmp.begin(), tmp.end(), pp);
		for (int i = 0; i < n; i++)
			cout << tmp[i].first << " ";
		cout << endl;

	}
return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct {
	bool operator()(pair<int,int> b, pair<int,int> c) {
		return b.first - c.second > c.first - b.second;
	}
}pp;
int main()
{
	int t,n;
	cin >> t;
	while (t--)
	{
		cin >> n;
		vector<pair<int,int>>tmp;
		for (int i = 0; i < n; i++)
		{
			int k;
			cin >> k;
			tmp.push_back(pair<int,int>(k,i));

		}
		sort(tmp.begin(), tmp.end(), pp);
		for (int i = 0; i < n; i++)
			cout << tmp[i].first << " ";
		cout << endl;

	}
return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int partition(vector<pair<int, int>>&tmp, int low, int high)
{
	int pivot = tmp[high].second-tmp[high].first ;
	int left = low;
	int right = high - 1;
	while (true) {
		while (left <= right && tmp[left].second-tmp[left].first  < pivot) left++;
		while (right >= left && tmp[right].second-tmp[right].first  > pivot) right--;
		if (left >= right) break;
		swap(tmp[left].first, tmp[right].first);
		left++;
		right--;
	}
	swap(tmp[left].first, tmp[high].first);
	return left;
}
void quickSort(vector<pair<int, int>>&tmp, int low, int high)
{
	if (low < high)
	{

		int pi = partition(tmp, low, high);

		quickSort(tmp, low, pi - 1);
		quickSort(tmp, pi + 1, high);
	}
}
int main()
{
	int t, n;
	cin >> t;
	while (t--)
	{
		cin >> n;
		vector<pair<int, int>>tmp;
		for (int i = 0; i < n; i++)
		{
			int k;
			cin >> k;
			tmp.push_back(pair<int, int>(k, i));

		}
		quickSort(tmp, 0, n - 1);
		for (int i = 0; i < n; i++)
			cout << tmp[i].first << " ";
		cout << endl;

	}
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct {
	bool operator()(pair<int,int> &b, pair<int,int> &c) {
		if (b.first - c.second < c.first - b.second)
		{
			swap(b.second, c.second);
			return true;
		}
		return false;

	}
}pp;
void main()
{
	int t,n;
	cin >> t;
	while (t--)
	{
		cin >> n;
		vector<pair<int,int>>tmp;
		for (int i = 0; i < n; i++)
		{
			int k;
			cin >> k;
			tmp.push_back(pair<int,int>(k,i));

		}
		sort(tmp.begin(), tmp.end(), pp);
		for (int i = 0; i < n; i++)
			cout << tmp[i].first << " ";
		cout << endl;

	}
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void bogsort()
{
	struct {
		bool operator()(int a, int b) {
			return a > b;

		}
	}pp;
	int t,n;
	cin >> t;

	while (t--)
	{
		cin >> n;
		vector<int>a;
		for (int i = 0; i < n; i++)
		{
			int k;
			cin >> k;
			a.push_back(k);
		}
		sort(a.begin(), a.end(), pp);

		for (int i = 0; i < n; i++)
			cout << a[i] << " ";
		cout << endl;
	}
}

void main()
{
	bogsort();
}


#include <bits/stdc++.h>
using namespace std;

long long n,m,t,a[999],b[999];
int main(){
	cin>>t;
	while(t--){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	reverse(a,a+n);
		for(int i=0;i<n;i++)
			cout<<a[i]<<" ";
		cout<<endl;
		}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n,m,t,a[999],b[999];
void swap(int &a,int &b){
	int tmp=a;
	a=b;
	b=tmp;
}
int main(){
	cin>>t;
	while(t--){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	reverse(a,a+n);
		for(int i=0;i<n;i++)
			cout<<a[i]<<" ";
		cout<<endl;
		}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n,m,t,a[999],b[999];
void swap(int &a,int &b){
	int tmp=a;
	a=b;
	b=tmp;
}
int main(){
	cin>>t;
	while(t--){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
		sort(a,a+n);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(i-a[i]==j-a[j])swap(a[i],a[j]);
		for(int i=0;i<n;i++)
			cout<<a[i]<<" ";
		cout<<endl;
		}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n,m,t,a[999],b[999];
void swap(int &a,int &b){
	int tmp=a;
	a=b;
	b=tmp;
}
int main(){
	cin>>t;
	while(t--){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	reveerse(a,a+n);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(i-a[i]==j-a[j])swap(a[i],a[j]);
		for(int i=0;i<n;i++)
			cout<<a[i]<<" ";
		cout<<endl;
		}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n,m,t,a[999],b[999];
void swap(int &a,int &b){
	int tmp=a;
	a=b;
	b=tmp;
}
int main(){
	cin>>t;
	while(t--){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=1;i<n;i++)
		if(i<n-1){
			if(abs(a[i]-a[i-1])==1)swap(a[i],a[i+1]);
		}
		else swap(a[0],a[n-1]);
		for(int i=0;i<n;i++)
			cout<<a[i]<<" ";
		cout<<endl;
		}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n,m,t,a[999],b[999];
void swap(int &a,int &b){
	int tmp=a;
	a=b;
	b=tmp;
}
int main(){
	cin>>t;
	while(t--){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=1;i<n;i++){
		for(int j=0;j<i;j++){
			if(i-a[i]==j-a[j])swap(a[i],a[j]);
		}
	}
		for(int i=0;i<n;i++)
			cout<<a[i]<<" ";
		cout<<endl;
		}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n,m,t,a[999],b[999];
void swap(int &a,int &b){
	int tmp=a;
	a=b;
	b=tmp;
}
int main(){
	cin>>t;
	while(t--){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(i-a[i]==j-a[j])swap(a[i],a[j]);
		for(int i=0;i<n;i++)
			cout<<a[i]<<" ";
		cout<<endl;
		}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n,m,t,a[999],b[999];
void swap(int &a,int &b){
	int tmp=a;
	a=b;
	b=tmp;
}
int main(){
	cin>>t;
	while(t--){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
		for(int i=0;i<n;i++)
			cout<<a[i]<<" ";
		cout<<endl;
		}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

void printArray(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << "\n";
}

int main()
{
    int test;
    cin >> test;
    while (test--)
    {
        int n;
        cin >> n;
        int arr[n];
        for (int i = 0; i < n; i++)
        {
            cin >> arr[i];
        }

        while (1)
        {
            vector<int> v;
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                v.push_back(i - arr[i]);
            }
            sort(v.begin(), v.end());
            for (int i = 0; i < n - 1; i++)
            {
                if (v[i] != v[i + 1])
                {
                    cnt++;
                }
            }
            if (cnt + 1 == n)
            {
                printArray(arr, n);
                break;
            }
            else
            {
                random_shuffle(&arr[0], &arr[n]);
            }
        }
    }

    return 0;
}