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

const int N = 100000 + 10;
int a[N], d[N], s[N], t[N];
int n;

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
        d[i] = a[i] - a[i + 1];
        if (d[i] < 0) d[i] = -d[i];
    }

    s[n - 2] = t[n - 2] = d[n - 2];
    for (int i = n - 3; i >= 0; i--) {
        s[i] = max(d[i] - t[i + 1], d[i]);
        t[i] = min(d[i] - s[i + 1], d[i]);
    }

    cout << s[0] << endl;

    return 0;
}


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

const int N = 100000 + 10;
int a[N];
int d[N], s[N], t[N];
int n;

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
        d[i] = a[i] - a[i + 1];
        if (d[i] < 0) d[i] = -d[i];
    }

    s[n - 2] = t[n - 2] = d[n - 2];
    for (int i = n - 3; i >= 0; i--) {
        s[i] = max(d[i] - t[i + 1], d[i]);
        t[i] = min(d[i] - s[i + 1], d[i]);
    }
    int mx = INT_MIN;
    for (int i = 0; i < n - 1; i++)
        mx = max(mx, s[i]);

    cout << mx << endl;

    return 0;
}


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

const int N = 100000 + 10;
int a[N], d[N], s[N], t[N];
int n;

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
        d[i] = a[i] - a[i + 1];
        if (d[i] < 0) d[i] = -d[i];
    }

    s[n - 2] = t[n - 2] = d[n - 2];
    for (int i = n - 3; i >= 0; i--) {
        s[i] = max(d[i] - t[i + 1], 0);
        t[i] = min(d[i] - s[i + 1], 0);
    }

    cout << s[0] << endl;

    return 0;
}


#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;
int foo[123456];
int goo[123456];
int dp[123456];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",foo+i);
	for(int i=0;i<n-1;i++){
		int gh=foo[i]-foo[i+1];
		if(gh<0) gh=-gh;
		goo[i]=gh;
	}
	/*for(int i=0;i<n-1;i++){
		printf("%d ",goo[i]);
	}puts("");*/
	dp[0]=goo[0];
	int q=-1;
	for(int i=1;i<n-1;i++){
		if(dp[i-1]+q*goo[i]>goo[i]){
			dp[i]=dp[i-1]+q*goo[i];
			q=1;

		} else {
			dp[i]=goo[i];
			q=-1;

		}
		//printf("%d ",dp[i]);
	}
	//printf("\n");
	int maxs=0;
	for(int i=0;i<n-1;i++){
		if(maxs<dp[i]){
			maxs=dp[i];
		}
	}
	printf("%d\n",maxs);
	return 0;
}


#include <stdio.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
int foo[123456];
int goo[123456];
int dp[123456];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>foo[i];
	for(int i=0;i<n-1;i++){
		int gh=foo[i]-foo[i+1];
		if(gh<0) gh=-gh;
		goo[i]=gh;
	}
	dp[0]=goo[0];
	dp[1]=goo[1];
	int q;
	for(int i=0;i<n-1;i+=2){
		if(i+2<n-1){
			int a=goo[i]-goo[i+1]+goo[i+2];
			if(a>goo[i+2]) dp[i+2]=a;
			else dp[i+2]=goo[i+2];
		}
		goo[i+2]=dp[i+2];
	}
	for(int i=1;i<n-1;i+=2){
		if(i+2<n-1){
			int a=goo[i]-goo[i+1]+goo[i+2];
			if(a>goo[i+2]) dp[i+2]=a;
			else dp[i+2]=goo[i+2];
		}
		goo[i+2]=dp[i+2];
	}
	int maxs=0;
	for(int i=0;i<n-1;i++)
		maxs=max(maxs,goo[i]);
	cout<<maxs<<endl;
	return 0;
}


#include <stdio.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
int foo[123456];
int goo[123456];
int dp[123456];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>foo[i];
	for(int i=0;i<n-1;i++){
		int gh=foo[i]-foo[i+1];
		if(gh<0) gh=-gh;
		goo[i]=gh;
	}
	dp[0]=goo[0];
	dp[1]=goo[1];
	for(int i=0;i<n-1;i+=2){
		if(i+2<n-1){
			int a=goo[i]-goo[i+1]+goo[i+2];
			if(a>goo[i+2]) dp[i+2]=a;
			else dp[i+2]=goo[i+2];
		}
		if(i+3<n-1){
			int b=goo[i+1]-goo[i+2]+goo[i+3];
			if(b>goo[i+3]) dp[i+3]=b;
			else dp[i+3]=goo[i+3];
		}
		goo[i+2]=dp[i+2];
		goo[i+3]=dp[i+3];

	}
	int maxs=0;
	for(int i=0;i<n-1;i++)
		maxs=max(maxs,dp[i]);
	cout<<maxs<<endl;
	return 0;
}


#include <stdio.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
int foo[123456];
int goo[123456];
int dp[123456];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>foo[i];
	for(int i=0;i<n-1;i++){
		int gh=foo[i]-foo[i+1];
		if(gh<0) gh=-gh;
		goo[i]=gh;
	}
	dp[0]=goo[0];
	dp[1]=goo[1];
	int q;
	for(int i=0;i<n-1;i+=q){
		if(i+2<n-1){
			int a=goo[i]-goo[i+1]+goo[i+2];
			if(a>goo[i+2]) dp[i+2]=a;
			else dp[i+2]=goo[i+2];
			q=1;
		}
		if(i+3<n-1){
			int b=goo[i+1]-goo[i+2]+goo[i+3];
			if(b>goo[i+3]) dp[i+3]=b;
			else dp[i+3]=goo[i+3];
			q=2;
		}
		goo[i+2]=dp[i+2];
		goo[i+3]=dp[i+3];

	}
	int maxs=0;
	for(int i=0;i<n-1;i++)
		maxs=max(maxs,goo[i]);
	cout<<maxs<<endl;
	return 0;
}


#include <stdio.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
int foo[123456];
int goo[123456];
int koo[123456];
int dp[123456];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>foo[i];
	for(int i=0;i<n-1;i++){
		int gh=foo[i]-foo[i+1];
		if(gh<0) gh=-gh;
		goo[i]=gh;
		koo[i]=gh;
	}
	dp[0]=goo[0];
	dp[1]=goo[1];
	int q;
	for(int i=0;i<n-1;i+=2){
		if(i+2<n-1){
			int a=goo[i]-goo[i+1]+goo[i+2];
			if(a>goo[i+2]) dp[i+2]=a;
			else dp[i+2]=goo[i+2];
		}
		goo[i+2]=dp[i+2];
	}
	for(int i=1;i<n-1;i+=2){
		if(i+2<n-1){
			int a=koo[i]-koo[i+1]+koo[i+2];
			if(a>koo[i+2]) dp[i+2]=a;
			else dp[i+2]=koo[i+2];
		}
		koo[i+2]=dp[i+2];
	}
	int maxs=0;
	for(int i=0;i<n-1;i++)
		maxs=max(maxs,goo[i]);
	for(int i=0;i<n-1;i++)
		maxs=max(maxs,koo[i]);
	cout<<maxs<<endl;
	return 0;
}


#include <stdio.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
int foo[123456];
int goo[123456];
int dp[123456];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>foo[i];
	for(int i=0;i<n-1;i++){
		int gh=foo[i]-foo[i+1];
		if(gh<0) gh=-gh;
		goo[i]=gh;
	}
	dp[0]=goo[0];
	dp[1]=goo[1];
	int q;
	for(int i=0;i<n-1;i+=q){
		if(i+2<n-1){
			int a=goo[i]-goo[i+1]+goo[i+2];
			if(a>goo[i+2]) dp[i+2]=a;
			else dp[i+2]=goo[i+2];
			q=1;
		}
		if(i+3<n-1){
			int b=goo[i+1]-goo[i+2]+goo[i+3];
			if(b>goo[i+3]) dp[i+3]=b;
			else dp[i+3]=goo[i+3];
			q=2;
		}
		goo[i+2]=dp[i+2];
		goo[i+3]=dp[i+3];

	}
	int maxs=0;
	for(int i=0;i<n-1;i++)
		maxs=max(maxs,dp[i]);
	cout<<maxs<<endl;
	return 0;
}


#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;
int foo[123456];
int goo[123456];
int dp[123456];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",foo+i);
	for(int i=0;i<n-1;i++){
		int gh=foo[i]-foo[i+1];
		if(gh<0) gh=-gh;
		goo[i]=gh;
	}
	dp[0]=goo[0];
	dp[1]=goo[1];
	for(int i=0;i+2<n-1;i++){
		int a=goo[i]-goo[i+1]+goo[i+2];
		if(a>goo[i+2]) dp[i+2]=a;
	}
	int maxs=0;
	for(int i=0;i<n-1;i++)
		maxs=max(maxs,dp[i]);
	printf("%d\n",maxs);
	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
const int N=123456;
int ABS(int a) {
    return a>0?a:-a;
}
int a[N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        scanf("%d",&a[i]);
    }
    int z=1;
    long long s=0,maxs=0,mins=0;
    for(int i=0;i<n-1;i++){
        s+=(z*ABS(a[i]-a[i+1]));
        //cout<<s<<endl;
        if(s>maxs) maxs=s;
        if(s<mins) mins=s;
        z*=-1;
    }
    printf("%lld\n",maxs-mins);
    return 0;
}


#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;
int foo[123456];
int goo[123456];
int dp[123456];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",foo+i);
	for(int i=0;i<n-1;i++){
		int gh=foo[i]-foo[i+1];
		if(gh<0) gh=-gh;
		goo[i]=gh;
	}
	for(int i=0;i+2<n-1;i++){
		int a=goo[i]-goo[i+1]+goo[i+2];
		if(a>goo[i+2]) goo[i+2]=a;
	}
	int maxs=0;
	for(int i=0;i<n-1;i++)
		maxs=max(maxs,goo[i]);
	printf("%d\n",maxs);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int a[111111];
int main(){
    int n;cin>>n;
    for(int i = 0 ;i < n ; i++){
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

int main(){
    long long n;cin>>n;
    for(int i = 0 ;i < n ; i++){
        cin>>a[i];
    }
    vector<long long>ans1;
    vector<long long>ans2;
    int q=1;
    for(int i = 0 ; i < n-1 ; i++){
        long long x=abs(a[i]-a[i+1]) * q ;
        ans1.push_back(x);
        if(q==1)q=-1;else q=1;
    }
    q = 1;
    for(int i = 1 ; i < n-1 ; i++){
        long long x=abs(a[i]-a[i+1]) * q;
        ans2.push_back(x);
        if(q==1)q=-1;else q=1;
    }
    long long res1=ans1[0],temp1=ans1[0];
    for(int i = 1 ; i < ans1.size() ; i++){
        temp1=max(ans1[i],temp1+ans1[i]);
        res1=max(res1,temp1);
    }
    if(ans2.size()!=0){
    long long res2=ans2[0],temp2=ans2[0];
    for(int i = 1 ; i < ans2.size() ; i++){
        temp2=max(ans2[i],temp2+ans2[i]);
        res2=max(res2,temp2);
    }
    res1=max(res1,res2);
    }
    cout<<res1;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

int main(){
    long long n;cin>>n;
    for(int i = 0 ;i < n ; i++){
        cin>>a[i];
    }
    vector<long long>ans1;
    vector<long long>ans2;
    int q=1;
    for(int i = 0 ; i < n-1 ; i++){
        long long x=abs(a[i]-a[i+1]) * q ;
        ans1.push_back(x);
        if(q==1)q=-1;else q=1;
    }
    for(int i = 1 ; i < n-1 ; i++){
        long long x=abs(a[i]-a[i+1]) * q;
        ans2.push_back(x);
        if(q==1)q=-1;else q=1;
    }
    long long res1=ans1[0],temp1=ans1[0];
    for(int i = 1 ; i < ans1.size() ; i++){
        temp1=max(ans1[i],temp1+ans1[i]);
        res1=max(ans1[i],temp1);
    }
    long long res2=ans2[0],temp2=ans2[0];
    for(int i = 1 ; i < ans2.size() ; i++){
        temp2=max(ans2[i],temp2+ans2[i]);
        res2=max(ans2[i],temp2);
    }
    cout<<max(res1,res2);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

int main(){
    long long n;cin>>n;
    for(int i = 0 ;i < n ; i++){
        cin>>a[i];
    }
    vector<long long>ans1;
    vector<long long>ans2;
    int q=1;
    for(int i = 0 ; i < n-1 ; i++){
        long long x=abs(a[i]-a[i+1]) * q ;
        ans1.push_back(x);
        if(q==1)q=-1;else q=1;
    }
    q = 1;
    for(int i = 1 ; i < n-1 ; i++){
        long long x=abs(a[i]-a[i+1]) * q;
        ans2.push_back(x);
        if(q==1)q=-1;else q=1;
    }
    long long res1=ans1[0],temp1=ans1[0];
    for(int i = 1 ; i < ans1.size() ; i++){
        temp1=max(ans1[i],temp1+ans1[i]);
        res1=max(ans1[i],temp1);
    }
    if(ans2.size()!=0){
    long long res2=ans2[0],temp2=ans2[0];
    for(int i = 1 ; i < ans2.size() ; i++){
        temp2=max(ans2[i],temp2+ans2[i]);
        res2=max(ans2[i],temp2);
    }
    res1=max(res1,res2);
    }
    cout<<res1;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

int main(){
    long long n;cin>>n;
    for(int i = 0 ;i < n ; i++){
        cin>>a[i];
    }
    vector<long long>ans1;
    vector<long long>ans2;
    int q=1;
    for(int i = 0 ; i < n-1 ; i++){
        long long x=abs(a[i]-a[i+1]) * q ;
        ans1.push_back(x);
        if(q==1)q=-1;else q=1;
    }
    for(int i = 1 ; i < n-1 ; i++){
        long long x=abs(a[i]-a[i+1]) * q;
        ans2.push_back(x);
        if(q==1)q=-1;else q=1;
    }
    long long res1=ans1[0],temp1=ans1[0];
    for(int i = 1 ; i < ans1.size() ; i++){
        temp1=max(ans1[i],temp1+ans1[i]);
        res1=max(ans1[i],temp1);
    }
    if(ans2.size()!=0){
    long long res2=ans2[0],temp2=ans2[0];
    for(int i = 1 ; i < ans2.size() ; i++){
        temp2=max(ans2[i],temp2+ans2[i]);
        res2=max(ans2[i],temp2);
    }
    res1=max(res1,res2);
    }
    cout<<res1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000000];
int max_sum(int n,ll *b)
{
	ll ans=INT_MIN,temp=0;
	for(int i=0;i<n;++i)
	{
		temp+=b[i];
		if(ans<temp)
		{
			ans=temp;
			//cout<<ans<<"\n";
		}
		if(temp<0)
		{
			temp=0;
		}
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	ll b[1000000];
	ll c[1000000];
	for(int i=0;i<n;++i)
	cin>>a[i];
	for(int i=0;i<n-1;++i)
	{
		b[i]=abs(a[i+1]-a[i])*pow(-1,i);
	}
	for(int i=1;i<n-1;++i)
	{
		c[i-1]=-1*b[i];
	}
	ll ans=max(max_sum(n-1,b),max_sum(n-2,c));
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000000];
int max_sum(int n,int *b)
{
	ll ans=INT_MIN,temp=0;
	for(int i=0;i<n;++i)
	{
		temp+=b[i];
		if(ans<temp)
		{
			ans=temp;
			//cout<<ans<<"\n";
		}
		if(temp<0)
		{
			temp=0;
		}
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	ll b[1000000];
	ll c[1000000];
	for(int i=0;i<n;++i)
	cin>>a[i];
	for(int i=0;i<n-1;++i)
	{
		b[i]=abs(a[i+1]-a[i])*pow(-1,i);
	}
	for(int i=1;i<n-1;++i)
	{
		c[i-1]=-1*b[i];
	}
	ll ans=max(max_sum(n-1,b),max_sum(n-2,c));
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1000000];
int max_sum(int n,ll *b)
{
	ll ans=INT_MIN,temp=0;
	for(int i=0;i<n;++i)
	{
		temp+=b[i];
		if(ans<temp)
		{
			ans=temp;
			//cout<<ans<<"\n";
		}
		if(temp<0)
		{
			temp=0;
		}
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	ll b[1000000];
	ll c[1000000];
	for(int i=0;i<n;++i)
	cin>>a[i];
	for(int i=0;i<n-1;++i)
	{
		b[i]=abs(a[i+1]-a[i])*pow(-1,i);
	}
	for(int i=0;i<n-2;++i)
	{
		c[i]=-1*b[i+1];
	}
	ll ans=max(max_sum(n-1,b),max_sum(n-2,c));
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000000];
int max_sum(int n,int *b)
{
	ll ans=INT_MIN,temp=0;
	for(int i=0;i<n;++i)
	{
		temp+=b[i];
		if(ans<temp)
		{
			ans=temp;
			//cout<<ans<<"\n";
		}
		if(temp<0)
		{
			temp=0;
		}
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	int b[1000000];
	int c[1000000];
	for(int i=0;i<n;++i)
	cin>>a[i];
	for(int i=0;i<n-1;++i)
	{
		b[i]=abs(a[i+1]-a[i])*pow(-1,i);
	}
	for(int i=1;i<n-1;++i)
	{
		c[i-1]=-1*b[i];
	}
	ll ans=max(max_sum(n-1,b),max_sum(n-2,c));
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int max_sum(int n,int *b)
{
	int ans=INT_MIN,temp=0;
	for(int i=0;i<n;++i)
	{
		temp+=b[i];
		if(ans<temp)
		{
			ans=temp;
			//cout<<ans<<"\n";
		}
		if(temp<0)
		{
			temp=0;
		}
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	int b[1000000];
	int c[1000000];
	for(int i=0;i<n;++i)
	cin>>a[i];
	for(int i=0;i<n-1;++i)
	{
		b[i]=abs(a[i+1]-a[i])*pow(-1,i);
	}
	for(int i=1;i<n-1;++i)
	{
		c[i]=-1*b[i];
	}
	int ans=max(max_sum(n-1,b),max_sum(n-2,c));
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000000];
int max_sum(int n,ll *b)
{
	ll ans=INT_MIN,temp=0;
	for(int i=0;i<n;++i)
	{
		temp+=b[i];
		if(ans<temp)
		{
			ans=temp;
			//cout<<ans<<"\n";
		}
		if(temp<0)
		{
			temp=0;
		}
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	ll b[1000000];
	ll c[1000000];
	for(int i=0;i<n;++i)
	cin>>a[i];
	for(int i=0;i<n-1;++i)
	{
		b[i]=abs(a[i+1]-a[i])*pow(-1,i);
	}
	for(int i=0;i<n-2;++i)
	{
		c[i]=-1*b[i+1];
	}
	ll ans=max(max_sum(n-1,b),max_sum(n-2,c));
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000000];
ll max_sum(int n,ll *b)
{
	ll ans=INT_MIN,temp=0;
	for(int i=0;i<n;++i)
	{
		temp+=b[i];
		if(ans<temp)
		{
			ans=temp;
			//cout<<ans<<"\n";
		}
		if(temp<0)
		{
			temp=0;
		}
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	ll b[1000000];
	ll c[1000000];
	for(int i=0;i<n;++i)
	cin>>a[i];
	for(int i=0;i<n-1;++i)
	{
		b[i]=abs(a[i+1]-a[i])*pow(-1,i);
	}
	for(int i=1;i<n-1;++i)
	{
		c[i-1]=-1*b[i];
	}
	ll ans=max(max_sum(n-1,b),max_sum(n-2,c));
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int b[1000000];
int max_sum(int n)
{
	int ans=INT_MIN,temp=0;
	for(int i=0;i<n;++i)
	{
		temp+=b[i];
		if(ans<temp)
		{
			ans=temp;
		}
		if(temp<0)
		{
			temp=0;
		}
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;++i)
	cin>>a[i];
	for(int i=0;i<n-1;++i)
	{
		b[i]=abs(a[i+1]-a[i])*pow(-1,i);
	}
	int ans=max_sum(n);
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int max_sum(int n,int *b)
{
	int ans=INT_MIN,temp=0;
	for(int i=0;i<n;++i)
	{
		temp+=b[i];
		if(ans<temp)
		{
			ans=temp;
			//cout<<ans<<"\n";
		}
		if(temp<0)
		{
			temp=0;
		}
	}
	return ans;
}
int main()
{
	int n;
	cin>>n;
	int b[1000000];
	int c[1000000];
	for(int i=0;i<n;++i)
	cin>>a[i];
	for(int i=0;i<n-1;++i)
	{
		b[i]=abs(a[i+1]-a[i])*pow(-1,i);
	}
	for(int i=1;i<n-1;++i)
	{
		c[i-1]=-1*b[i];
	}
	int ans=max(max_sum(n-1,b),max_sum(n-2,c));
	cout<<ans;
	return 0;
}


#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

vector<long> a,b;
long n;

void solve() {
	vector<long long> dp_min(n), dp_max(n);
	dp_min[n-1] = dp_max[n-1] = 0;

	for(long i=n-2; i>=0; i--) {
		dp_max[i] = max(b[i], b[i]-dp_min[i+1]);
		dp_min[i] = min(b[i], b[i]-dp_max[i+1]);
	}

	long long res = dp_max[0];
	for(long i=1; i<n-1; i++) res = max(res, dp_max[i]);
	printf("%I64d\n", res);
}

int main() {
	scanf("%ld", &n);
	a.resize(n), b.resize(n);
	for(long i=0; i<n; i++) scanf("%ld", &a[i]);
	for(long i=0; i<n-1; i++) b[i] = fabs(a[i+1]-a[i]);

	solve();

	return 0;
}


#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

vector<long long> a,b;
long long n;

void solve() {
	vector<long long> dp_min(n), dp_max(n);
	dp_min[n-1] = dp_max[n-1] = 0;

	for(long long i=n-2; i>=0; i--) {
		dp_max[i] = max(b[i], b[i]-dp_min[i+1]);
		dp_min[i] = min(b[i], b[i]-dp_max[i+1]);
	}

	long long res = dp_max[0];
	for(long long i=1; i<n-1; i++) res = max(res, dp_max[i]);
	printf("%I64d\n", res);
}

int main() {
	scanf("%I64d", &n);
	a.resize(n), b.resize(n);
	for(long long i=0; i<n; i++) scanf("%I64d", &a[i]);
	for(long long i=0; i<n-1; i++) b[i] = fabs(a[i+1]-a[i]);

	solve();

	return 0;
}


#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

vector<long> a,b;
long n;

void solve() {
	vector<long> dp_min(n), dp_max(n);
	dp_min[n-1] = dp_max[n-1] = 0;

	for(long i=n-2; i>=0; i--) {
		dp_max[i] = max(b[i], b[i]-dp_min[i+1]);
		dp_min[i] = min(b[i], b[i]-dp_max[i+1]);
	}

	long res = dp_max[0];
	for(long i=1; i<n-1; i++) res = max(res, dp_max[i]);
	printf("%ld\n", res);
}

int main() {
	scanf("%ld", &n);
	a.resize(n), b.resize(n);
	for(long i=0; i<n; i++) scanf("%ld", &a[i]);
	for(long i=0; i<n-1; i++) b[i] = fabs(a[i+1]-a[i]);

	solve();

	return 0;
}


#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

vector<long> a,b;
long n;

void solve() {
	vector<long long> dp_min(n), dp_max(n);
	dp_min[n-1] = dp_max[n-1] = 0;

	for(long i=n-2; i>=0; i--) {
		dp_max[i] = max((long long)b[i], b[i]-dp_min[i+1]);
		dp_min[i] = min((long long)b[i], b[i]-dp_max[i+1]);
	}

	long long res = dp_max[0];
	for(long i=1; i<n-1; i++) res = max(res, dp_max[i]);
	printf("%I64d\n", res);
}

int main() {
	scanf("%ld", &n);
	a.resize(n), b.resize(n);
	for(long i=0; i<n; i++) scanf("%ld", &a[i]);
	for(long i=0; i<n-1; i++) b[i] = fabs(a[i+1]-a[i]);

	solve();

	return 0;
}


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

vector<long long> a,b;
long long n;

void solve() {
	vector<long long> dp_min(n), dp_max(n);
	dp_min[n-1] = dp_max[n-1] = 0;

	for(long long i=n-2; i>=0; i--) {
		dp_max[i] = max(b[i], b[i]-dp_min[i+1]);
		dp_min[i] = min(b[i], b[i]-dp_max[i+1]);
	}

	long long res = dp_max[0];
	for(long long i=1; i<n-1; i++) res = max(res, dp_max[i]);
	cout<<res<<endl;
}

int main() {
	cin>>n;
	a.resize(n), b.resize(n);
	for(long long i=0; i<n; i++) cin>>a[i];
	for(long long i=0; i<n-1; i++) b[i] = fabs(a[i+1]-a[i]);

	solve();

	return 0;
}


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

vector<long long> a,b;
long long n;

void solve() {
	vector<long long> dp_min(n), dp_max(n);
	dp_min[n-1] = dp_max[n-1] = 0;

	for(long long i=n-2; i>=0; i--) {
		dp_max[i] = max(b[i], b[i]-dp_min[i+1]);
		dp_min[i] = min(b[i], b[i]-dp_max[i+1]);
	}

	long long res = dp_max[0];
	for(long long i=1; i<n-1; i++) res = max(res, dp_max[i]);
	cout<<res<<endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin>>n;
	a.resize(n), b.resize(n);
	for(long long i=0; i<n; i++) cin>>a[i];
	for(long long i=0; i<n-1; i++) b[i] = fabs(a[i+1]-a[i]);

	solve();

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define clr(x) memset(x,0,sizeof(x))
#define LL long long
using namespace std;
int a[100010];
LL minodd,maxeven;
int main()
{
	int n;
	LL ans,all;
	scanf("%d",&n);
	minodd=1e10;
	maxeven=-1e10;
	all=0;
	ans=0;
	scanf("%d",&a[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i&1)
			all+=1LL*abs(a[i]-a[i-1]);
		else
			all-=1LL*abs(a[i]-a[i-1]);
//		printf("%d\n",all);
//		printf("%d %d\n",maxeven,minodd);
		if(i&1 && maxeven<all)
		{
			maxeven=all;
		}
		if((i&1)==0 && minodd>all)
		{
			minodd=all;
		}
		if(maxeven-all>ans)
			ans=maxeven-all;
		if(all-minodd>ans)
			ans=all-minodd;
	}
	printf("%lld\n",ans);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define clr(x) memset(x,0,sizeof(x))
using namespace std;
int a[100010];
int minodd,maxeven;
int main()
{
	int n,pre,ans,all;
	scanf("%d",&n);
	minodd=1e9;
	maxeven=0;
	all=0;
	ans=0;
	scanf("%d",&a[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pre=abs(a[i]-a[i-1]);
		if((i&1)==0)
			pre*=-1;
		all+=pre;
//		printf("%d\n",all);
//		printf("%d %d\n",maxeven,minodd);
		if(maxeven-all>ans)
			ans=maxeven-all;
		if(all-minodd>ans)
			ans=all-minodd;
		if(i&1 && maxeven<all)
		{
			maxeven=all;
		}
		if(i&1==0 && minodd>all)
		{
			minodd=all;
		}
	}
	if(maxeven-all>ans)
		ans=maxeven-pre;
	if(all-minodd>ans)
		ans=pre-minodd;
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define clr(x) memset(x,0,sizeof(x))
#define LL long long
using namespace std;
int a[100010];
LL minodd,maxeven;
int main()
{
	int n,pre;
	LL ans,all;
	scanf("%d",&n);
	minodd=1e10;
	maxeven=0;
	all=0;
	ans=0;
	scanf("%d",&a[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pre=abs(a[i]-a[i-1]);
		if((i&1)==0)
			pre*=-1;
		all+=1LL*pre;
//		printf("%d\n",all);
//		printf("%d %d\n",maxeven,minodd);
		if(i&1 && maxeven<all)
		{
			maxeven=all;
		}
		if(i&1==0 && minodd>all)
		{
			minodd=all;
		}
		if(maxeven-all>ans)
			ans=maxeven-all;
		if(all-minodd>ans)
			ans=all-minodd;
	}
	printf("%lld\n",ans);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define clr(x) memset(x,0,sizeof(x))
#define LL long long
using namespace std;
int a[100010];
LL minodd,maxeven;
int main()
{
	int n;
	LL ans,all;
	scanf("%d",&n);
	minodd=1e10;
	maxeven=0;
	all=0;
	ans=-1e10;
	scanf("%d",&a[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i&1)
			all+=1LL*abs(a[i]-a[i-1]);
		else
			all-=1LL*abs(a[i]-a[i-1]);
//		printf("%d\n",all);
//		printf("%d %d\n",maxeven,minodd);
		if(i&1 && maxeven<all)
		{
			maxeven=all;
		}
		if((i&1)==0 && minodd>all)
		{
			minodd=all;
		}
		if(maxeven-all>ans)
			ans=maxeven-all;
		if(all-minodd>ans)
			ans=all-minodd;
	}
	printf("%lld\n",ans);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define clr(x) memset(x,0,sizeof(x))
using namespace std;
int a[100010];
int minodd,maxeven;
int main()
{
	int n,pre,ans,all;
	scanf("%d",&n);
	minodd=1e9;
	maxeven=0;
	all=0;
	ans=0;
	scanf("%d",&a[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pre=abs(a[i]-a[i-1]);
		if((i&1)==0)
			pre*=-1;
		all+=pre;
//		printf("%d\n",all);
//		printf("%d %d\n",maxeven,minodd);
		if(i&1 && maxeven<all)
		{
			maxeven=all;
		}
		if(i&1==0 && minodd>all)
		{
			minodd=all;
		}
		if(maxeven-all>ans)
			ans=maxeven-all;
		if(all-minodd>ans)
			ans=all-minodd;
	}
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#define MAXN 100000

int main()
{
	int num, a[MAXN], f[MAXN];
	scanf("%d", &num);
	for(int i = 0; i < num; i++)
		scanf("%d", &a[i]);
	for(int i = 0; i < num - 1; i++)
	{
		if(i % 2 == 0)
			f[i] = abs(a[i] - a[i + 1]);
		else
			f[i] = abs(a[i] - a[i + 1]) * -1;
	}

	int max = 0, min = 0, low = 0, high = 0;
	for(int i = 0; i < num - 1; i++)
	{
		low += f[i], high += f[i];
		if(low > 0)	low = 0;
		if(high < 0)	high = 0;
		if(high > max) max = high;
		if(low < min) min = low;
	}
	int ans = (max > abs(min)) ? max : abs(min);
	printf("%d\n", ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#define MAXN 111111

int main()
{
	long long int num, a[MAXN], f[MAXN];
	scanf("%lld", &num);
	for(long long int i = 0; i < num; i++)
		scanf("%lld", &a[i]);
	for(long long int i = 0; i < num - 1; i++)
	{
		if(i % 2 == 0)
			f[i] = abs(a[i] - a[i + 1]);
		else
			f[i] = abs(a[i] - a[i + 1]) * -1;
	}

	long long int max = 0, min = 0, low = 0, high = 0;
	for(long long int i = 0; i < num - 1; i++)
	{
		low += f[i], high += f[i];
		if(high > max) max = high;
		if(low < min) min = low;
	}
	long long int ans = (max > abs(min)) ? max : abs(min);
	printf("%lld\n", ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#define MAXN 111111

int main()
{
	long long int num, a[MAXN], f[MAXN];
	scanf("%lld", &num);
	for(long long int i = 0; i < num; i++)
		scanf("%lld", &a[i]);
	for(long long int i = 0; i < num - 1; i++)
	{
		if(i % 2 == 0)
			f[i] = abs(a[i] - a[i + 1]);
		else
			f[i] = abs(a[i] - a[i + 1]) * -1;
	}

	long long int max = 0, min = 0, low = 0, high = 0;
	for(long long int i = 0; i < num - 1; i++)
	{
		low += f[i] * -1, high += f[i];
		if(low < 0) low = 0;
		if(high < 0) high = 0;
		if(high > max) max = high;
		if(low > min) min = low;
	}
	long long int ans = (max > min)? max : min;
	printf("%lld\n", ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#define MAXN 100000

int main()
{
	long long int a, ai[MAXN], f[MAXN], max = 0, now = 0;
	scanf("%lld", &a);
	for(int i = 0; i < a; i++)
		scanf("%lld", &ai[i]);

	for(int i = 0; i < a - 1; i++)
	{
		if(i % 2 == 0)
			f[i] = abs(ai[i] - ai[i + 1]);
		else
			f[i] = abs(ai[i] - ai[i + 1]) * -1;
	}
	for(int i = 0; i < a - 1; i++)
	{
		now += f[i];
		if(now < 0)
			now = 0;
		if(now > max)
			max = now;
	}
	printf("%lld\n", max);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define F first
#define S second
#define fr(i,a,b) for(int i = a;i<b;i++)
using namespace std;
double a[1005],b[1005];
double p;
int n;

bool ch(double m){

	fr(i,0,n)
	{
		double used = (m+p)/a[i];
		m-=used;
		if(m<0)
			return false;
		if(i!=n-1)
		used = (m+p)/b[i+1];
		else
		used = (m+p)/b[0];
		m-=used;
		if(m<0)
			return false;

	}
	return true;
}

int main()
{

	cin>>n;
	cin>>p;
	fr(i,0,n)
		cin>>a[i];
	fr(i,0,n)
		cin>>b[i];

		double l = 0 , r = 1e9+5;
		double m;
		if(!ch(1e9))
			cout<<"-1"<<endl,exit(0);
		while(abs(r-l) >=1e-6)
		{

		//	cout<<m<<endl;

				  m = (r+l)/2;
			if(ch(m))
				r = m;
			else
				l = m;
		}
	cout<<fixed<<setprecision(10)<<m<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define F first
#define S second
#define fr(i,a,b) for(int i = a;i<b;i++)
using namespace std;
int main()
{
	ll int n;
	cin>>n;
	double p;//b for landing
	cin>>p;
	double a[n],b[n];
	double x,w,z;
	ll int i;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		cin>>b[i];
	x=p/(b[0]-1);
	w=p+x;
	for(i=n-1;i>0;i--)
	{
		z=w/(a[i]-1);
		w=w+z;
		z=w/(b[i]-1);
		w=w+z;
	}
	z=w/(a[0]-1);
	w=w+z;
	if(isinf((w-p))==1)
		cout<<"-1\n";
	else
	cout<<fixed<<setprecision(10)<<(w-p)<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define F first
#define S second
#define fr(i,a,b) for(int i = a;i<b;i++)
using namespace std;
double a[1005],b[1005];
double p;
int n;

bool ch(double m){

	fr(i,0,n)
	{
		double used = (m+p)/a[i];
		m-=used;
		if(m<0)
			return false;
		if(i!=n-1)
		used = (m+p)/b[i+1];
		else
		used = (m+p)/b[0];
		m-=used;
		if(m<0)
			return false;

	}
	return true;
}

int main()
{

	cin>>n;
	cin>>p;
	fr(i,0,n)
		cin>>a[i];
	fr(i,0,n)
		cin>>b[i];

		double l = 0 , r = 1e10;
		double m;
		while(abs(r-l) > 1e-8)
		{

		//	cout<<m<<endl;
				  m = (r+l)/2;
			if(ch(m))
				r = m;
			else
				l = m;
		}
		if(m>1000000000)
			cout<<"-1\n";
		else
	cout<<fixed<<setprecision(10)<<m<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define F first
#define S second
#define fr(i,a,b) for(int i = a;i<b;i++)
using namespace std;
double a[1005],b[1005];
double p;
int n;

bool ch(double m){

	fr(i,0,n)
	{
		double used = (m+p)/a[i];
		m-=used;
		if(m<0)
			return false;
		if(i!=n-1)
		used = (m+p)/b[i+1];
		else
		used = (m+p)/b[0];
		m-=used;
		if(m<0)
			return false;

	}
	return true;
}

int main()
{

	cin>>n;
	cin>>p;
	fr(i,0,n)
		cin>>a[i];
	fr(i,0,n)
		cin>>b[i];

		double l = 0 , r = 1e9+5;
		double m;
		if(!ch(1e9))
			cout<<"-1"<<endl,exit(0);
		while(abs(r-l) > =1e-6)
		{

		//	cout<<m<<endl;

				  m = (r+l)/2;
			if(ch(m))
				r = m;
			else
				l = m;
		}
	cout<<fixed<<setprecision(10)<<m<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define F first
#define S second
#define fr(i,a,b) for(int i = a;i<b;i++)
using namespace std;
double a[1005],b[1005];
double p;
int n;

bool ch(double m){

	fr(i,0,n)
	{
		double used = (m+p)/a[i];
		m-=used;
		if(m<0)
			return false;
		if(i!=n-1)
		used = (m+p)/b[i+1];
		else
		used = (m+p)/b[0];
		m-=used;
		if(m<0)
			return false;

	}
	return true;
}

int main()
{

	cin>>n;
	cin>>p;
	fr(i,0,n)
		cin>>a[i];
	fr(i,0,n)
		cin>>b[i];

		double l = 0 , r = 1e9+5;
		double m;
		while(abs(r-l) > 1e-8)
		{

		//	cout<<m<<endl;
				  m = (r+l)/2;
			if(ch(m))
				r = m;
			else
				l = m;
		}
		if(m>1000000000)
			cout<<"-1\n";
		else
	cout<<fixed<<setprecision(10)<<m<<endl;
}


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

typedef long double ld;

int n, m;
int a[1010], b[1010];

int can(ld x) {
	ld init = x + m;
	if (init < m) return 0;
	for (int i = 0; i < n - 1; ++i) {
		ld need = init/a[i];
		init -= need;	if (init < m) return 0;

		need = init/b[i + 1];
		init -= need;
	if (init < m) return 0;
	}
	ld need = init/a[n - 1];
	init -= need;
	if (init < m) return 0;
	need = init/b[0];
	init -= need;
	if (init < m) return 0;
	return 1;
}

int main() {
	cout << fixed << setprecision(20);
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int j = 0; j < n; ++j)
		cin >> b[j];
	// cout << can(0) << endl;
	ld l = 0, r = 1e9;
	while (abs(r - l) > 1e-8) {
		ld m = (r + l)/2;
		if (can(m)) r = m;
		else l = m;
	}
	if (abs(l - 1e9) < 1e-6) cout << "-1\n";
	else cout << l << '\n';
}


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

typedef long double ld;

int n, m;
int a[1010], b[1010];

int can(ld x) {
	ld init = x + m;
	if (init < m) return 0;
	for (int i = 0; i < n - 1; ++i) {
		ld need = init/a[i];
		init -= need;	if (init < m) return 0;

		need = init/b[i + 1];
		init -= need;
	if (init < m) return 0;
	}
	ld need = init/a[n - 1];
	init -= need;
	if (init < m) return 0;
	need = init/b[0];
	init -= need;
	if (init < m) return 0;
	return 1;
}

int main() {
	cout << fixed << setprecision(20);
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int j = 0; j < n; ++j)
		cin >> b[j];
	// cout << can(0) << endl;
	ld l = 0, r = 1e9 + 10;
	while (abs(r - l) > 1e-8) {
		ld m = (r + l)/2;
		if (can(m)) r = m;
		else l = m;
	}
	if (l > 1e9) cout << "-1\n";
	else cout << l << '\n';
}


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

typedef long double ld;

int n, m;
int a[1010], b[1010];

int can(ld x) {
	ld init = x + m;
	if (init < m) return 0;
	for (int i = 0; i < n - 1; ++i) {
		ld need = init/a[i];
		init -= need;	if (init < m) return 0;

		need = init/b[i + 1];
		init -= need;
	if (init < m) return 0;
	}
	ld need = init/a[n - 1];
	init -= need;
	if (init < m) return 0;
	need = init/b[0];
	init -= need;
	if (init < m) return 0;
	return 1;
}

int main() {
	cout << fixed << setprecision(20);
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int j = 0; j < n; ++j)
		cin >> b[j];
	// cout << can(0) << endl;
	ld l = 0, r = 1e9;
	while (abs(r - l) > 1e-10) {
		ld m = (r + l)/2;
		if (can(m)) r = m;
		else l = m;
	}
	if (!can(1e9)) cout << "-1\n";
	else cout << l << '\n';
}


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

typedef long double ld;

int n, m;
int a[1010], b[1010];

int can(ld x) {
	ld init = x + m;
	for (int i = 0; i < n - 1; ++i) {
		ld need = init/a[i];
		init -= need;
		need = init/b[i + 1];
		init -= need;
	}
	ld need = init/a[n - 1];
	init -= need;
	need = init/b[0];
	init -= need;
	return init >= m;
}

int main() {
	cout << fixed << setprecision(20);
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int j = 0; j < n; ++j)
		cin >> b[j];
	// cout << can(0) << endl;
	ld l = 0, r = 1e9;
	while (abs(r - l) > 1e-8) {
		ld m = (r + l)/2;
		if (can(m)) r = m;
		else l = m;
	}
	if (!can(1e9)) cout << "-1\n";
	else cout << l << '\n';
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
int a[N], b[N];
double diff = 1.0e-8;
bool check(double mid) {
	double k = (double)m;
	double r = mid + k;
	int i;
	for (i = 0; i < n && (r-k)>=-diff; i++) {
		r -= r / (double)a[i];
		if (r-k < -diff) {
			return false;
		}
		r -= r / (double)b[i + 1];
	}
	return (r - k) >= -diff;
}
void solve() {
	int i;
	double x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
	}
	b[n] = b[0];
	if (!flag) {
		printf("-1\n");
		return;
	}
	x = 0.0;
	y = 1.0e9;
	int c = 0;
	while (x - y >= diff || x - y <= -diff) {
		c++;
		mid = (x + y) / 2.0;
		if (check(mid)) {
			y = mid;
		}
		else {
			x = mid;
		}
		if (c > 60) {
			printf("%.8lf %.8lf\n", x, y);
			return;
		}
	}
	//printf("Count=%d\n", c);
	if (x >= 1.0e9 || 1.0e9 - x <= diff) {
		printf("-1\n");
	}
	else {
		printf("%.6lf\n", x);
	}
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	double x = 804389417.199715;
	double y = 804389417.199715;
	bool flag = (x - y >= diff || x - y <= -diff);
	//printf("%d\n", flag);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
int a[N], b[N];
double diff = 1.0e-8;
bool check(double mid) {
	double k = (double)m;
	double r = mid + k;
	int i;
	for (i = 0; i < n && (r-k)>=-diff; i++) {
		r -= r / (double)a[i];
		if (r-k < -diff) {
			return false;
		}
		r -= r / (double)b[i + 1];
	}
	return (r - k) >= -diff;
}
void solve() {
	int i;
	double x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
	}
	b[n] = b[0];
	if (!flag) {
		printf("-1\n");
		return;
	}
	x = 0.0;
	y = 1.0e9;
	int c = 0;
	while (x - y >= diff || x - y <= -diff) {
		c++;
		mid = (x + y) / 2.0;
		if (check(mid)) {
			y = mid;
		}
		else {
			x = mid;
		}
		if (c > 60) {
			printf("%.6lf %.6lf\n", x, y);
			return;
		}
	}
	//printf("Count=%d\n", c);
	if (x >= 1.0e9 || 1.0e9 - x <= diff) {
		printf("-1\n");
	}
	else {
		printf("%.6lf\n", x);
	}
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
long long a[N], b[N];
long long X = 1e8;
bool check(long long mid) {
	long long k = m * X;
	long long r = mid + k;
	int i;
	for (i = 0; i < n && r >= k; i++) {
		r -= (r * X /a[i]);
		if (r < k) {
			return 0;
		}
		r -= (r * X/ b[i + 1]);
	}
	return r >= k;
}
void solve() {
	int i;
	long long x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
		a[i] *= X;
	}
	for (i = 0; i < n; i++) {
		scanf("%lld", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
		b[i] *= X;
	}
	b[n] = b[0];
	if (!flag) {
		printf("-1\n");
		return;
	}
	x = 0;
	long long maxn = 1e9;
	maxn *= X;
	y = maxn;
	int c = 0;
	while (x < y) {
		c++;
		mid = (x + y) / 2;
		if (check(mid)) {
			y = mid;
		}
		else {
			x = mid + 1;
		}
	}
	//printf("Count=%d\n", c);
	if (x >= maxn) {
		printf("-1\n");
	}
	else {
		double ans = (double)x / (double)X;
		printf("%.6lf\n", ans);
	}
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
int a[N], b[N];
double diff = 1.0e-8;
bool check(double mid) {
	double k = (double)m;
	double r = mid + k;
	int i;
	for (i = 0; i < n && (r-k)>=-diff; i++) {
		r -= r / (double)a[i];
		if (r-k < -diff) {
			return false;
		}
		r -= r / (double)b[i + 1];
	}
	return (r - k) >= -diff;
}
void solve() {
	int i;
	double x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
	}
	b[n] = b[0];
	if (!flag) {
		printf("-1\n");
		return;
	}
	x = 0.0;
	y = 1.0e9;
	int c = 0;
	while (x - y >= diff || x - y <= -diff) {
		c++;
		mid = (x + y) / 2.0;
		if (check(mid)) {
			y = mid;
		}
		else {
			x = mid;
		}
	}
	//printf("Count=%d\n", c);
	if (x >= 1.0e9 || 1.0e9 - x <= diff) {
		printf("-1\n");
	}
	else {
		printf("%.6lf\n", x);
	}
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
int a[N], b[N];
double diff = 1.0e-8;
bool check(double mid) {
	double k = (double)m;
	double r = mid + k;
	int i;
	for (i = 0; i < n && (r-k)>=-diff; i++) {
		r -= r / (double)a[i];
		if (r-k < -diff) {
			return false;
		}
		r -= r / (double)b[i + 1];
	}
	return (r - k) >= -diff;
}
void solve() {
	int i;
	double x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
	}
	b[n] = b[0];
	if (!flag) {
		printf("-1\n");
		return;
	}
	x = 0.0;
	y = 1.0e9;
	int c = 0;
	while (x - y >= diff || x - y <= -diff) {
		c++;
		mid = (x + y) / 2.0;
		if (check(mid)) {
			y = mid;
		}
		else {
			x = mid;
		}
		if (c > 55) {
			printf("...........\n");
			return;
		}
	}
	//printf("Count=%d\n", c);
	if (x >= 1.0e9 || 1.0e9 - x <= diff) {
		printf("-1\n");
	}
	else {
		printf("%.6lf\n", x);
	}
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
int a[N], b[N];
double diff = 1.0e-8;
bool check(double mid) {
	double k = (double)m;
	double r = mid + k;
	int i;
	for (i = 0; i < n && (r-k)>=-diff; i++) {
		r -= r / (double)a[i];
		if (r-k < -diff) {
			return false;
		}
		r -= r / (double)b[i + 1];
	}
	return (r - k) >= -diff;
}
void solve() {
	int i;
	double x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
	}
	b[n] = b[0];
	if (!flag) {
		printf("-1\n");
		return;
	}
	x = 0.0;
	y = 1.0e9;
	int c = 0;
	while (x - y >= diff || x - y <= -diff) {
		c++;
		mid = (x + y) / 2.0;
		if (check(mid)) {
			y = mid;
		}
		else {
			x = mid;
		}
		if (c > 60) {
			printf("...........\n");
			return;
		}
	}
	//printf("Count=%d\n", c);
	if (x >= 1.0e9 || 1.0e9 - x <= diff) {
		printf("-1\n");
	}
	else {
		printf("%.6lf\n", x);
	}
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
int a[N], b[N];
double diff = 1.0e-8;
bool check(double mid) {
	double k = (double)m;
	double r = mid + k;
	int i;
	for (i = 0; i < n && (r - k) >= -diff; i++) {
		r -= r / (double)a[i];
		if (r - k < -diff) {
			return false;
		}
		r -= r / (double)b[i + 1];
	}
	return (r - k) >= -diff;
}
void solve() {
	int i;
	double x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
	}
	b[n] = b[0];
	if (!flag) {
		printf("-1\n");
		return;
	}
	mid = (double)m;
	for (i = n - 1; i >= 0; i--) {
		x = mid / (double)(b[i + 1] - 1);
		mid += x;
		x = mid / (double)(a[i] - 1);
		mid += x;
	}
	printf("%.6lf\n", mid - (double)m);
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
int a[N], b[N];
double diff = 1.0e-8;
bool check(double mid) {
	double k = (double)m;
	double r = mid + k;
	int i;
	for (i = 0; i < n && (r-k)>=-diff; i++) {
		r -= r / (double)a[i];
		if (r < k) {
			return false;
		}
		r -= r / (double)b[(i+1)%n];
	}
	return (r - k) >= -diff;
}
void solve() {
	int i;
	double x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
	}
	if (!flag) {
		printf("-1\n");
		return;
	}
	x = 0.0;
	y = 1.0e9;
	int c = 0;
	while (x - y >= diff || x - y <= -diff) {
		c++;
		mid = (x + y) / 2.0;
		if (check(mid)) {
			y = mid;
		}
		else {
			x = mid;
		}
	}
	//printf("Count=%d\n", c);
	if (x >= 1.0e9 || 1.0e9 - x <= diff) {
		printf("-1\n");
	}
	else {
		printf("%.6lf\n", x);
	}
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
int a[N], b[N];
double diff = 1.0e-8;
bool check(double mid) {
	double k = (double)m;
	double r = mid + k;
	int i;
	for (i = 0; i < n && (r - k) >= -diff; i++) {
		r -= r / (double)a[i];
		if (r - k < -diff) {
			return false;
		}
		r -= r / (double)b[i + 1];
	}
	return (r - k) >= -diff;
}
void solve() {
	int i;
	double x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
	}
	b[n] = b[0];
	if (!flag) {
		printf("-1\n");
		return;
	}
	x = 0.0;
	y = 1.0e9;
	int c = 0;
	while (x - y >= diff || x - y <= -diff) {
		c++;
		mid = (x + y) / 2.0;
		if (check(mid)) {
			y = mid;
		}
		else {
			x = mid;
		}
		if (c > 60) {
			break;
		}
	}
	//printf("Count=%d\n", c);
	if (x >= 1.0e9 || 1.0e9 - x <= diff) {
		printf("-1\n");
	}
	else {
		printf("%.6lf\n", x);
	}
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#define N 3060
#define M 401000
//#define MAXN 1125899906842624L
#define MAXVAL 1000000000
#define MAXN 520*520
#define MOD 998244353
int n, m;
long long a[N], b[N];
long long X = 1e8;
bool check(long long mid) {
	long long k = m * X;
	long long r = mid + k;
	int i;
	for (i = 0; i < n && r >= k; i++) {
		r -= (r * X /a[i]);
		if (r < k) {
			return 0;
		}
		r -= (r * X/ b[i + 1]);
	}
	return r >= k;
}
void solve() {
	int i;
	long long x, y, mid;
	bool flag = 1;
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		if (a[i] == 1) {
			flag = 0;
		}
		a[i] *= X;
	}
	for (i = 0; i < n; i++) {
		scanf("%lld", &b[i]);
		if (b[i] == 1) {
			flag = 0;
		}
		b[i] *= X;
	}
	b[n] = b[0];
	printf("%d\n", check(10 * X));
	if (!flag) {
		printf("-1\n");
		return;
	}
	x = 0;
	long long maxn = 1e9;
	maxn *= X;
	y = maxn;
	int c = 0;
	while (x < y) {
		c++;
		mid = (x + y) / 2;
		if (check(mid)) {
			y = mid;
		}
		else {
			x = mid + 1;
		}
	}
	//printf("Count=%d\n", c);
	if (x >= maxn) {
		printf("-1\n");
	}
	else {
		double ans = (double)x / (double)X;
		printf("%.6lf\n", ans);
	}
}
int main() {
	//int tc;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll n,m;
ll a[1001],b[1001];

bool f(ld x) {
    x-=(m+x)/a[0];
    repf(i,1,n) {
        x-=(m+x)/b[i];
        x-=(m+x)/a[i];
    }
    x-=(m+x)/b[0];
    return x>=0;
}

void solve(ll tt) {
    cin>>n>>m;
    repf(i,0,n) cin>>a[i];
    repf(i,0,n) cin>>b[i];
    ld lo=0,hi=1e9,mid,ans=2e9;
    repf(i,0,1000) {
        mid=(lo+hi)/2;
        if(f(mid)) {
            ans=mid;
            hi=mid;
        }
        else lo=mid;
    }
    if(ans<=1e9) cout<<fixed<<setprecision(10)<<ans<<endl;
    else cout<<-1<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll n,m;
ll a[1001],b[1001];

bool f(ld x) {
    x-=(m+x)/a[0];
    repf(i,1,n) {
        x-=(m+x)/b[i];
        x-=(m+x)/a[i];
    }
    x-=(m+x)/b[0];
    return x>=0;
}

void solve(ll tt) {
    cin>>n>>m;
    repf(i,0,n) cin>>a[i];
    repf(i,0,n) cin>>b[i];
    ld lo=0,hi=1e9,mid,ans=2e9;
    repf(i,0,1000) {
        mid=(lo+hi)/2;
        if(f(mid)) {
            ans=mid;
            hi=mid;
        }
        else lo=mid;
    }
    if(ans>1e9) cout<<-1<<endl;
    else cout<<fixed<<setprecision(10)<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll n,m;
ll a[1001],b[1001];

bool f(ld x) {
    x-=(m+x)/a[0];
    repf(i,1,n) {
        x-=(m+x)/b[i];
        x-=(m+x)/a[i];
    }
    x-=(m+x)/b[0];
    return x>=0;
}

void solve(ll tt) {
    cin>>n>>m;
    repf(i,0,n) cin>>a[i];
    repf(i,0,n) cin>>b[i];
    ld lo=0,hi=1e9+10,mid,ans=hi;
    repf(i,0,2000) {
        mid=(lo+hi)/2;
        if(f(mid)) {
            ans=min(ans,mid);
            hi=mid;
        }
        else lo=mid;
    }
    if(ans>1e9+1) cout<<-1<<endl;
    else cout<<fixed<<setprecision(10)<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll n,m;
ll a[1001],b[1001];

bool f(ld x) {
    x-=(m+x)/a[0];
    repf(i,1,n) {
        x-=(m+x)/b[i];
        x-=(m+x)/a[i];
    }
    x-=(m+x)/b[0];
    return x>=0;
}

void solve(ll tt) {
    cin>>n>>m;
    repf(i,0,n) cin>>a[i];
    repf(i,0,n) cin>>b[i];
    ld lo=0,hi=1e9,mid,ans=hi+5;
    repf(i,0,1000) {
        mid=(lo+hi)/2;
        if(f(mid)) {
            ans=min(ans,mid);
            hi=mid;
        }
        else lo=mid;
    }
    if(ans>hi+1) cout<<-1<<endl;
    else cout<<fixed<<setprecision(10)<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll n,m;
ll a[1001],b[1001];

bool f(ld x) {
    x-=(m+x)/a[0];
    repf(i,1,n) {
        x-=(m+x)/b[i];
        x-=(m+x)/a[i];
    }
    x-=(m+x)/b[0];
    return x>=0;
}

void solve(ll tt) {
    cin>>n>>m;
    repf(i,0,n) cin>>a[i];
    repf(i,0,n) cin>>b[i];
    ld lo=0,hi=1e9,mid,ans=2e9;
    repf(i,0,1000) {
        mid=(lo+hi)/2;
        if(f(mid)) {
            ans=min(ans,mid);
            hi=mid;
        }
        else lo=mid;
    }
    if(ans>1e9) cout<<-1<<endl;
    else cout<<fixed<<setprecision(10)<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll n,m;
ll a[1001],b[1001];

bool f(ld x) {
    x-=(m+x)/a[0];
    repf(i,1,n) {
        x-=(m+x)/b[i];
        x-=(m+x)/a[i];
    }
    x-=(m+x)/b[0];
    return x>=0;
}

void solve(ll tt) {
    cin>>n>>m;
    repf(i,0,n) cin>>a[i];
    repf(i,0,n) cin>>b[i];
    ld lo=0,hi=1e9,mid,ans=2e9;
    repf(i,0,1000) {
        mid=(lo+hi)/2;
        if(f(mid)) {
            ans=mid;
            hi=mid;
        }
        else lo=mid;
    }
    if(f(ans)) cout<<fixed<<setprecision(10)<<ans<<endl;
    else cout<<-1<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll n,m;
ll a[1001],b[1001];

bool f(ld x) {
    x-=(m+x)/a[0];
    repf(i,1,n) {
        x-=(m+x)/b[i];
        x-=(m+x)/a[i];
    }
    x-=(m+x)/b[0];
    return x>=0;
}

void solve(ll tt) {
    cin>>n>>m;
    repf(i,0,n) cin>>a[i];
    repf(i,0,n) cin>>b[i];
    ld lo=0,hi=1e9,mid,ans=1e9;
    repf(i,0,1000) {
        mid=(lo+hi)/2;
        if(f(mid)) {
            ans=mid;
            hi=mid;
        }
        else lo=mid;
    }
    if(f(ans)) cout<<fixed<<setprecision(10)<<ans<<endl;
    else cout<<-1<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll n,m;
ll a[1001],b[1001];

bool f(ld x) {
    x-=(m+x)/a[0];
    repf(i,1,n) {
        x-=(m+x)/b[i];
        x-=(m+x)/a[i];
    }
    x-=(m+x)/b[0];
    return x>=0;
}

void solve(ll tt) {
    cin>>n>>m;
    repf(i,0,n) cin>>a[i];
    repf(i,0,n) cin>>b[i];
    ld lo=0,hi=1e9,mid,ans=1e9;
    repf(i,0,1000) {
        mid=(lo+hi)/2;
        if(f(mid)) {
            ans=min(ans,mid);
            hi=mid;
        }
        else lo=mid;
    }
    if(f(ans)) cout<<fixed<<setprecision(10)<<ans<<endl;
    else cout<<-1<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll n,m;
ll a[1001],b[1001];

bool f(ld x) {
    x-=(m+x)/a[0];
    repf(i,1,n) {
        x-=(m+x)/b[i];
        x-=(m+x)/a[i];
    }
    x-=(m+x)/b[0];
    return x>=0;
}

void solve(ll tt) {
    cin>>n>>m;
    repf(i,0,n) cin>>a[i];
    repf(i,0,n) cin>>b[i];
    ld lo=0,hi=1e9,mid,ans=hi+5;
    repf(i,0,2000) {
        mid=(lo+hi)/2;
        if(f(mid)) {
            ans=min(ans,mid);
            hi=mid;
        }
        else lo=mid;
    }
    if(ans>hi+1) cout<<-1<<endl;
    else cout<<fixed<<setprecision(10)<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}


/*author : Yashvardhan
Sunday, June 02, 2019
1:50 PM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;}
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;}
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

const int N = 1000;

vector<double> lift(N);
vector<double> land(N);
int n,m;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

bool check(double x){
	double tl = x + m;
	double c = tl/lift[0];
	x -= c;

	for(int i = 1; i < n ; i++){
		double ml = x + m;
		double c = ml/land[i];
		x -= c;

		tl = x + m;
		c = tl/lift[i];
		x -= c;
	}

	double ml = x + m;
	c = ml/land[0];
	x -= c;

	if(x < 0) return false;
	return true;

}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();

	cin>>n>>m;

	cout<<setprecision(10)<<fixed;

	for(int i = 0; i < n ; i++){
		cin>>lift[i];
	}

	for(int i = 0; i < n ; i++){
		cin>>land[i];
	}

	double r = 1000000000;
	double l = 0;
	double ans = -1;

	while(l <= r){
		double mid = (l+r)/2;
		if(check(mid)){
			ans = mid;
			r = mid - 0.0000001;
		}
		else{
			l = mid + 0.0000001;
		}
	}

	cout<<ans<<endl;

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;

	return 0;
}


/*author : Yashvardhan
Sunday, June 02, 2019
1:50 PM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;}
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;}
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

const int N = 1000;

vector<double> lift(N);
vector<double> land(N);
int n,m;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

bool check(double x){
	double tl = x + m;
	double c = tl/lift[0];
	x -= c;

	for(int i = 1; i < n ; i++){
		double ml = x + m;
		double c = ml/land[i];
		x -= c;

		tl = x + m;
		c = tl/lift[i];
		x -= c;
	}

	double ml = x + m;
	c = ml/land[0];
	x -= c;

	if(x < 0) return false;
	return true;

}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();

	cin>>n>>m;

	cout<<setprecision(10)<<fixed;

	for(int i = 0; i < n ; i++){
		cin>>lift[i];
	}

	for(int i = 0; i < n ; i++){
		cin>>land[i];
	}

	double r = 10000000000;
	double l = 0;
	double ans = -1;

	while(l <= r){
		double mid = (l+r)/2;
		if(check(mid)){
			ans = mid;
			r = mid - 0.0000001;
		}
		else{
			l = mid + 0.0000001;
		}
	}

	cout<<ans<<endl;

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;

	return 0;
}


/*author : Yashvardhan
Sunday, June 02, 2019
1:50 PM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;}
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;}
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

const int N = 1000;

vector<double> lift(N);
vector<double> land(N);
int n,m;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

bool check(double x){
	double tl = x + m;
	double c = tl/lift[0];
	x -= c;

	for(int i = 1; i < n ; i++){
		double ml = x + m;
		double c = ml/land[i];
		x -= c;

		tl = x + m;
		c = tl/lift[i];
		x -= c;
	}

	double ml = x + m;
	c = ml/land[0];
	x -= c;

	if(x < 0) return false;
	return true;

}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();

	cin>>n>>m;

	cout<<setprecision(10)<<fixed;

	for(int i = 0; i < n ; i++){
		cin>>lift[i];
	}

	for(int i = 0; i < n ; i++){
		cin>>land[i];
	}

	double r = 1000000000;
	double l = 0;
	double ans = -1;

	while(l <= r){
		double mid = (l+r)/2;
		if(check(mid)){
			ans = mid;
			r = mid - 0.000001;
		}
		else{
			l = mid + 0.000001;
		}
	}

	cout<<ans<<endl;

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;

	return 0;
}


/*author : Yashvardhan
Sunday, June 02, 2019
1:50 PM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;}
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;}
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

const int N = 1000;

vector<double> lift(N);
vector<double> land(N);
int n,m;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

bool check(double x){
	double tl = x + m;
	double c = tl/lift[0];
	x -= c;

	for(int i = 1; i < n ; i++){
		double ml = x + m;
		double c = ml/land[i];
		x -= c;

		tl = x + m;
		c = tl/lift[i];
		x -= c;
	}

	double ml = x + m;
	c = ml/land[0];
	x -= c;

	if(x < 0) return false;
	return true;

}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();

	cin>>n>>m;

	cout<<setprecision(10)<<fixed;

	for(int i = 0; i < n ; i++){
		cin>>lift[i];
	}

	for(int i = 0; i < n ; i++){
		cin>>land[i];
	}

	double r = 1000000009;
	double l = 0;
	double ans = -1;

	while(l <= r){
		double mid = (l+r)/2;
		if(check(mid)){
			ans = mid;
			r = mid - 0.000001;
		}
		else{
			l = mid + 0.000001;
		}
	}

	cout<<ans<<endl;

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;

	return 0;
}


/*
Author : N_o_o_B
Created : April 14 2020 22:00:37
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}

template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}

template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,m;
    cin >> n >> m;
    vi a(n),b(n);
    fori(i,n) cin >> a[i];
    fori(i,n) cin >> b[i];
    ld lo = 0,hi = 1e18;
    ld EPS = 1e-12;
    ld ans = hi;
    while(hi - lo > EPS){
        ld mid = (lo + hi)/2;
        ld tot = m + mid;
        tot -= tot/a[0];
        rep(i,1,n-1){
            tot -= tot/b[i];
            tot -= tot/a[i];
        }
        tot -= tot/b[0];
        if(tot >= m){
            ans = mid;
            hi = mid-EPS;
        }
        else{
            lo = mid+EPS;
        }
    }
    cout << (ans > 1e9 ? -1 : ans) << endl;

    time_taken();
    return 0;
}


/*
Author : N_o_o_B
Created : April 14 2020 22:00:37
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}

template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}

template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,m;
    cin >> n >> m;
    vi a(n),b(n);
    fori(i,n) cin >> a[i];
    fori(i,n) cin >> b[i];
    ld lo = 0,hi = 1e9+1e-6;
    ld EPS = 1e-9;
    ld ans = -1;
    while(hi - lo > EPS){
        ld mid = (lo + hi)/2;
        ld tot = m + mid;
        tot -= tot/a[0];
        rep(i,1,n-1){
            tot -= tot/b[i];
            tot -= tot/a[i];
        }
        tot -= tot/b[0];
        if(tot >= m){
            ans = mid;
            hi = mid-EPS;
        }
        else{
            lo = mid+EPS;
        }
    }
    cout << ans << endl;

    time_taken();
    return 0;
}


/*
Author : N_o_o_B
Created : April 14 2020 22:00:37
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}

template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}

template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,m;
    cin >> n >> m;
    vi a(n),b(n);
    fori(i,n) cin >> a[i];
    fori(i,n) cin >> b[i];
    ld lo = 0,hi = 1e9;
    ld EPS = 1e-9;
    ld ans = -1;
    while(hi - lo > EPS){
        ld mid = (lo + hi)/2;
        ld tot = m + mid;
        tot -= tot/a[0];
        rep(i,1,n-1){
            tot -= tot/b[i];
            tot -= tot/a[i];
        }
        tot -= tot/b[0];
        if(tot >= m){
            ans = mid;
            hi = mid-EPS;
        }
        else{
            lo = mid+EPS;
        }
    }
    cout << ans << endl;

    time_taken();
    return 0;
}


/*
Author : N_o_o_B
Created : April 14 2020 22:00:37
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}

template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}

template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,m;
    cin >> n >> m;
    vi a(n),b(n);
    fori(i,n) cin >> a[i];
    fori(i,n) cin >> b[i];
    ld lo = 0,hi = 1e18;
    ld EPS = 1e-6;
    ld ans = hi;
    while(hi - lo > EPS){
        ld mid = (lo + hi)/2;
        ld tot = m + mid;
        tot -= tot/a[0];
        rep(i,1,n-1){
            tot -= tot/b[i];
            tot -= tot/a[i];
        }
        tot -= tot/b[0];
        if(tot >= m){
            ans = mid;
            hi = mid-EPS;
        }
        else{
            lo = mid+EPS;
        }
    }
    cout << (ans > 1e9 ? -1 : ans) << endl;

    time_taken();
    return 0;
}


#include <bits/stdc++.h>
#define r(a, b) for(int i = a; i < b; i++)
#define pb push_back
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
const ll N = 1e3+5, mod = 1e9+7;
int n, m, a[N], b[N];

bool check(double f){
    bool ans = true;
    for(int i = 0; i < n; i++){
        if((m + f)/a[i] <= f){
            f -= (m + f)/a[i];
        }
        else{
            ans = false;
            break;
        }
        if((m + f)/b[(i+1)%n] <= f){
            f -= (m+f)/b[(i+1)%n];
        }
        else{
            ans = false;
            break;
        }
    }
    return ans;
}

int main(){
    FastIO
    #ifndef ONLINE_JUDGE
        freopen("Input.txt", "r", stdin);
        freopen("Output.txt", "w", stdout);
    #endif
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    double l = 0, h = 1e9+7;
    while(h-l >= 1e-6){
        double mid = (l+h)/2;
        if(check(mid))
            h = mid;
        else l = mid;
    }
    if(h >= 1e9) cout << -1;
    else cout << fixed << setprecision(7) << h;
}


#include <bits/stdc++.h>
#define r(a, b) for(int i = a; i < b; i++)
#define pb push_back
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
const ll N = 1e3+5, mod = 1e9+7;
int n, m, a[N], b[N];

bool check(double f){
    bool ans = true;
    for(int i = 0; i < n; i++){
        if((m + f)/a[i] <= f){
            f -= (m + f)/a[i];
        }
        else{
            ans = false;
            break;
        }
        if((m + f)/b[(i+1)%n] <= f){
            f -= (m+f)/b[(i+1)%n];
        }
        else{
            ans = false;
            break;
        }
    }
    return ans;
}

int main(){
    FastIO
    #ifndef ONLINE_JUDGE
        freopen("Input.txt", "r", stdin);
        freopen("Output.txt", "w", stdout);
    #endif
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    double l = 0, h = 1e9+7;
    while(h-l >= 1e-6){
        double mid = (l+h)/2;
        if(check(mid))
            h = mid;
        else l = mid;
    }
    if(h > 1e9+4) cout << -1;
    else cout << fixed << setprecision(7) << h;
}


#include <bits/stdc++.h>
#define r(a, b) for(int i = a; i < b; i++)
#define pb push_back
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
const ll N = 1e3+5, mod = 1e9+7;
int n, m, a[N], b[N];

bool check(double f){
    bool ans = true;
    for(int i = 0; i < n; i++){
        if((m + f)/a[i] <= f){
            f -= (m + f)/a[i];
        }
        else{
            ans = false;
            break;
        }
        if((m + f)/b[(i+1)%n] <= f){
            f -= (m+f)/b[(i+1)%n];
        }
        else{
            ans = false;
            break;
        }
    }
    return ans;
}

int main(){
    FastIO
    #ifndef ONLINE_JUDGE
        freopen("Input.txt", "r", stdin);
        freopen("Output.txt", "w", stdout);
    #endif
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    double l = 0, h = 1e9+7;
    while(h-l >= 1e-6){
        double mid = (l+h)/2;
        if(check(mid))
            h = mid;
        else l = mid;
    }
    if(h > 1e9) cout << -1;
    else cout << fixed << setprecision(7) << h;
}


#include <bits/stdc++.h>
#define r(a, b) for(int i = a; i < b; i++)
#define pb push_back
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
const ll N = 1e3+5, mod = 1e9+7;
int n, m, a[N], b[N];

bool check(double f){
    bool ans = true;
    for(int i = 0; i < n; i++){
        if((m + f)/a[i] <= f){
            f -= (m + f)/a[i];
        }
        else{
            ans = false;
            break;
        }
        if((m + f)/b[(i+1)%n] <= f){
            f -= (m+f)/b[(i+1)%n];
        }
        else{
            ans = false;
            break;
        }
    }
    return ans;
}

int main(){
    FastIO
    #ifndef ONLINE_JUDGE
        freopen("Input.txt", "r", stdin);
        freopen("Output.txt", "w", stdout);
    #endif
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    double l = 0, h = 1e9+1;
    while(h-l >= 1e-6){
        double mid = (l+h)/2;
        if(check(mid))
            h = mid;
        else l = mid;
    }
    if(h > 1e9) cout << -1;
    else cout << fixed << setprecision(7) << h;
}


#include <bits/stdc++.h>
#define r(a, b) for(int i = a; i < b; i++)
#define pb push_back
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
const ll N = 1e3+5, mod = 1e9+7;
int n, m, a[N], b[N];

bool check(double f){
    bool ans = true;
    for(int i = 0; i < n; i++){
        if((m + f)/a[i] <= f){
            f -= (m + f)/a[i];
        }
        else{
            ans = false;
            break;
        }
        if((m + f)/b[(i+1)%n] <= f){
            f -= (m+f)/b[(i+1)%n];
        }
        else{
            ans = false;
            break;
        }
    }
    return ans;
}

int main(){
    FastIO
    #ifndef ONLINE_JUDGE
        freopen("Input.txt", "r", stdin);
        freopen("Output.txt", "w", stdout);
    #endif
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    double l = 0, h = 1e9+1;
    while(h-l >= 1e-6){
        double mid = (l+h)/2;
        if(check(mid))
            h = mid;
        else l = mid;
    }
    if(h > 1e9) cout << -1;
    else cout << h;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll arr1[1005];
ll arr2[1005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n, m;
	cin >> n >> m;
	for (ll i = 0; i < n; i++) {
		cin >> arr1[i];
	}
	for (ll i = 0; i < n; i++) {
		cin >> arr2[i];
	}
	ld l = 0, r = 1e9 + 5;
	for (ll i = 0; i < 1000; i++) {
		ld mid = (l + r) / 2.0;
		ld fuel = mid;
		ld req = 1.0 * ((fuel + m)/(arr1[0]));
		if (req > fuel) {
			l = mid;
			continue;
		}
		fuel -= req;
		for (ll j = 1; j < n; j++) {
			req = 1.0 * ((fuel + m)/(arr2[j]));
			if (req > fuel) {
				l = mid;
				continue;
			}
			fuel -= req;
			req = 1.0 * ((fuel + m)/(arr1[j]));
			if (req > fuel) {
				l = mid;
				continue;
			}
			fuel -= req;
		}
		req = 1.0 * ((fuel + m)/(arr2[0]));
		if (req > fuel) {
			l = mid;
			continue;
		}
		r = mid;
	}
	if (l > 1e9) {
		cout << -1 << endl;
		return 0;
	}
	cout << fixed << setprecision(10);
	cout << l << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll arr1[1005];
ll arr2[1005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n, m;
	cin >> n >> m;
	for (ll i = 0; i < n; i++) {
		cin >> arr1[i];
	}
	for (ll i = 0; i < n; i++) {
		cin >> arr2[i];
	}
	ld l = 0, r = 1e9;
	ll f = 0;
	for (ll i = 0; i < 500; i++) {
		ld mid = (l + r) / 2.0;
		ld fuel = mid;
		ld req = 1.0 * ((fuel + m)/(arr1[0]));
		if (req > fuel) {
			l = mid;
			continue;
		}
		fuel -= req;
		for (ll j = 1; j < n; j++) {
			req = 1.0 * ((fuel + m)/(arr2[j]));
			if (req > fuel) {
				l = mid;
				continue;
			}
			fuel -= req;
			req = 1.0 * ((fuel + m)/(arr1[j]));
			if (req > fuel) {
				l = mid;
				continue;
			}
			fuel -= req;
		}
		req = 1.0 * ((fuel + m)/(arr2[0]));
		if (req > fuel) {
			l = mid;
			continue;
		}
		f = 1;
		r = mid;
	}
	if (f == 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << fixed << setprecision(10);
	cout << l << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ld arr1[1005];
ld arr2[1005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n;
	ld m;
	cin >> n >> m;
	for (ll i = 0; i < n; i++) {
		cin >> arr1[i];
	}
	for (ll i = 0; i < n; i++) {
		cin >> arr2[i];
	}
	ld eps = 1e-10;
	ld l = 0, r = 1e9 + eps;
	ll ch = 0;
	for (ll i = 0; i < 200; i++) {
		ld mid = (l + r) / 2.0;
		ld fuel = mid;
		ld req = ((fuel + m)/(arr1[0]));
		ll f = 0;
		if (req > fuel) {
			f = 1;
		}
		fuel -= req;
		for (ll j = 1; j < n; j++) {
			req = ((fuel + m)/(arr2[j]));
			if (req > fuel) {
				f = 1;
				break;
			}
			fuel -= req;
			req = ((fuel + m)/(arr1[j]));
			if (req > fuel) {
				f = 1;
				break;
			}
			fuel -= req;
		}
		req = ((fuel + m)/(arr2[0]));
		if (req > fuel) {
			f = 1;
		}
		fuel -= req;
		if (f == 1)
			l = mid;
		else {
			ch = 1;
			r = mid;
		}
	}
	if (ch == 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << fixed << setprecision(10);
	cout << r << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll arr1[1005];
ll arr2[1005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n, m;
	cin >> n >> m;
	for (ll i = 0; i < n; i++) {
		cin >> arr1[i];
	}
	for (ll i = 0; i < n; i++) {
		cin >> arr2[i];
	}
	ld l = 0, r = 1e9 + 5;
	for (ll i = 0; i < 500; i++) {
		ld mid = (l + r) / 2.0;
		ld fuel = mid;
		ld req = 1.0 * ((fuel + m)/(arr1[0]));
		if (req > fuel) {
			l = mid;
			continue;
		}
		fuel -= req;
		for (ll j = 1; j < n; j++) {
			req = 1.0 * ((fuel + m)/(arr2[j]));
			if (req > fuel) {
				l = mid;
				continue;
			}
			fuel -= req;
			req = 1.0 * ((fuel + m)/(arr1[j]));
			if (req > fuel) {
				l = mid;
				continue;
			}
			fuel -= req;
		}
		req = 1.0 * ((fuel + m)/(arr2[0]));
		if (req > fuel) {
			l = mid;
			continue;
		}
		r = mid;
	}
	if (l > 1e9) {
		cout << -1 << endl;
		return 0;
	}
	cout << fixed << setprecision(10);
	cout << l << endl;
	return 0;
}