#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,A,B) for(int i=A;i<=B;i++)
#define mod 1000000007
#define v1d vector<int>
#define v2d vector<vector<int>>
#define v1s vector<string>
#define v2s vector<vector<string> >
#define v1l vector<double>
#define v2l vector<vector<double> >

bool check(v1d &a,v1d &b,double p,int n,int m){
    double x= (m+p)/(1.0*a[0]);
    p-=x;
    for(int i=1;i<=n-1&&p>0;i++){
        x= (m+p)/(1.0*b[i]);
        p-=x;
        x= (m+p)/(1.0*a[i]);
        p-=x;
        if(p<0)return false;
    }
    x= (m+p)/(1.0*b[0]);
    p-=x;
    if(p<0){
        return false;
    }
    return true;
}

int32_t main(){
    IOS;
    cout.precision(6);
    int n,m;cin>>n>>m;
    v1d a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    int p= 1000000000;
    /*if(check(a,b,85.47,n,m)){
        cout<<"haha";
    }
    if(check(a,b,85.48,n,m)){
        cout<<"ha";
    }*/
    int s=0,e=p;
    while(s<=e){
        int mid=(s+e)/2;
        if(check(a,b,mid,n,m)){
            p=min(p,mid);
            e=mid-1;
        }
        else{
            s=mid+1;
        }
    }
    if(p>=1000000000){
        cout<<-1;return 0;
    }
    bool flag=false;
    double res=p-1;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            for(int k=0;k<=9;k++){
                double q=res+ (i*100.0+j*10.0+k*1.0)/1000.0;
                if(check(a,b,q,n,m)){
                    cout<<q;return 0;
                }
            }
        }
    }
    cout<<p;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e3 + 5;
const double eps = 1e-9;
int a[N], b[N], n, m;
bool check(double x) {
	for (int i = 0; i < n; i ++) {
		double t = (x + m) / a[i];
		x -= t;
		if(x < 0) return false;
		t = (x + m) / b[(i+1) % n];
		x -= t;
		if(x < 0) return false;
	}
	return true;
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	double l = 0, r = 1e9+1, m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	for (int i = 0; i < 1200; i++) {
		if(fabs(m2-m1) < eps) break;
		if(!check(m1)) l = m1;
		else if(!check(m2)) r = m2;
		else r = m2;
		m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	}
	double ans = (m1+m2)/2;
	if(!check(ans)) printf("-1\n");
	else printf("%.10f\n", ans);
	return 0;
}
/*
2
12
11 8
7 5
*/


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e3 + 5;
const double eps = 1e-9;
int a[N], b[N], n, m;
bool check(double x) {
	for (int i = 0; i < n; i ++) {
		double t = (x + m) / a[i];
		x -= t;
		if(x < 0) return false;
		t = (x + m) / b[(i+1) % n];
		x -= t;
		if(x < 0) return false;
	}
	return true;
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	double l = 0, r = 1e9, m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	for (int i = 0; i < 400; i++) {
		if(!check(m1)) l = m1;
		else if(!check(m2)) r = m2;
		else r = m2;
		//cout << l << " " << r << endl;
		m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	}
	double ans = (m1+m2)/2;
	//cout << ans << endl;
	if(!check(ans)) printf("-1\n");
	else printf("%.10f\n", ans);
	return 0;
}
/*
2
12
11 8
7 5
*/


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e3 + 5;
int a[N], b[N];
int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) scanf("%d", &b[i]);
    double ans = 0;
    for (int i = n; i >= 1; i--) {
        if(b[i%n] == 1 || a[i-1] == 1) return 0*puts("-1");
        ans = (ans * b[i%n] + m) / (b[i%n] - 1);
        ans = (ans * a[i-1] + m) / (a[i-1] - 1);
    }
    printf("%.12f\n", ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e3 + 5;
const double eps = 1e-9;
int a[N], b[N], n, m;
bool check(double x) {
	for (int i = 0; i < n; i ++) {
		double t = (x + m) / a[i];
		x -= t;
		if(x < 0) return false;
		t = (x + m) / b[(i+1) % n];
		x -= t;
		if(x < 0) return false;
	}
	return true;
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	double l = 0, r = 1e9, m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	while(l + eps < r) {
		if(!check(m1)) l = m1;
		else if(!check(m2)) r = m2;
		else r = m2;
		//cout << l << " " << r << endl;
		m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	}
	double ans = (m1+m2)/2;
	//cout << ans << endl;
	if(!check(ans)) printf("-1\n");
	else printf("%.10f\n", ans);
	return 0;
}
/*
2
12
11 8
7 5
*/


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e3 + 5;
const double eps = 1e-9;
int a[N], b[N], n, m;
bool check(double x) {
	for (int i = 0; i < n; i ++) {
		double t = (x + m) / a[i];
		x -= t;
		if(x < 0) return false;
		t = (x + m) / b[(i+1) % n];
		x -= t;
		if(x < 0) return false;
	}
	return true;
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	double l = 0, r = 1e9, m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	for (int i = 0; i < 400; i++) {
	    if(fabs(m2-m1) < eps) break;
		if(!check(m1)) l = m1;
		else if(!check(m2)) r = m2;
		else r = m2;
		//cout << l << " " << r << endl;
		m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	}
	double ans = (m1+m2)/2;
	//cout << ans << endl;
	if(!check(ans)) printf("-1\n");
	else printf("%.10f\n", ans);
	return 0;
}
/*
2
12
11 8
7 5
*/


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e3 + 5;
const double eps = 1e-7;
int a[N], b[N], n, m;
bool check(double x) {
	for (int i = 0; i < n; i ++) {
		double t = (x + m) / a[i];
		x -= t;
		if(x < 0) return false;
		t = (x + m) / b[(i+1) % n];
		x -= t;
		if(x < 0) return false;
	}
	return true;
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	double l = 0, r = 1e9+1, m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	for (int i = 0; i < 800; i++) {
		if(fabs(m2-m1) < eps) break;
		if(!check(m1)) l = m1;
		else if(!check(m2)) r = m2;
		else r = m2;
		m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	}
	double ans = (m1+m2)/2;
	if(!check(ans)) printf("-1\n");
	else printf("%.10f\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e3 + 5;
const double eps = 1e-7;
int a[N], b[N], n, m;
bool check(double x) {
	for (int i = 0; i < n; i ++) {
		double t = (x + m) / a[i];
		x -= t;
		if(x < -eps) return false;
		t = (x + m) / b[(i+1) % n];
		x -= t;
		if(x < -eps) return false;
	}
	return true;
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	double l = 0, r = 1e9+1, m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	for (int i = 0; i < 800; i++) {
		if(fabs(m2-m1) < eps) break;
		if(!check(m1)) l = m1;
		else if(!check(m2)) r = m2;
		else r = m2;
		m1 = (l+l+r) / 3, m2 = (l+r+r) / 3;
	}
	double ans = (m1+m2)/2;
	if(!check(ans)) printf("-1\n");
	else printf("%.10f\n", ans);
	return 0;
}
/*
2
12
11 8
7 5
*/


#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define double long double
const int N = 1e3 + 5;
const double eps = 1e-6;

int n;
double m, a[N], b[N];

bool check(double val) {
	double w = m + val;
	int ok = 1;
	for (int i = 1; i <= n; i++) {
		double used = w / a[i];
		w -= used;
		if (w < m) {
			ok = 0;
			break;
		}

		used = w / b[i + 1];
		w -= used;
		if (w < m) {
			ok = 0;
			break;
		}
	}
	return ok;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> b[i];
	a[n + 1] = a[1];
	b[n + 1] = b[1];

	double L = 0, R = 1e9;
	while (R - L > eps) {
		double mid = (L + R) / 2.0;
		if (check(mid)) {
			R = mid;
		} else {
			L = mid;
		}
	}

	if (check(L)) {
		cout << fixed << setprecision(10) << L;
	} else {
		if (check(R)) {
			cout << fixed << setprecision(10) << R;
		} else {
			cout << -1;
		}
	}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
const int N = 1e3 + 5;
const double eps = 1e-10;

int n;
double m, a[N], b[N];

bool check(double val) {
	double w = m + val;
	int ok = 1;
	for (int i = 1; i <= n; i++) {
		double used = w / a[i];
		w -= used;
		if (w < m) {
			ok = 0;
			break;
		}

		used = w / b[i + 1];
		w -= used;
		if (w < m) {
			ok = 0;
			break;
		}
	}
	return ok;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> b[i];
	a[n + 1] = a[1];
	b[n + 1] = b[1];

	double L = 0, R = 1e9;
	while (R - L > eps) {
		double mid = (L + R) / 2.0;
		if (check(mid)) {
			R = mid;
		} else {
			L = mid;
		}
	}

	if (check(R)) {
		cout << fixed << setprecision(10) << R;
	} else {
		cout << -1;
	}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
const int N = 1e3 + 5;
const double eps = 1e-7;

int n;
double m, a[N], b[N];

bool check(double val) {
	double w = m + val;
	int ok = 1;
	for (int i = 1; i <= n; i++) {
		double used = w / a[i];
		w -= used;
		if (w < m) {
			ok = 0;
			break;
		}

		used = w / b[i + 1];
		w -= used;
		if (w < m) {
			ok = 0;
			break;
		}
	}
	return ok;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> b[i];
	a[n + 1] = a[1];
	b[n + 1] = b[1];

	double L = 0, R = 1e9;
	while (R - L > eps) {
		double mid = (L + R) / 2.0;
		if (check(mid)) {
			R = mid;
		} else {
			L = mid;
		}
	}

	if (check(L)) {
		cout << fixed << setprecision(10) << L;
	} else {
		if (check(R)) {
			cout << fixed << setprecision(10) << R;
		} else {
			cout << -1;
		}
	}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
const int N = 1e3 + 5;
const double eps = 1e-6;

int n;
double m, a[N], b[N];

bool check(double val) {
	double w = m + val;
	int ok = 1;
	for (int i = 1; i <= n; i++) {
		double used = w / a[i];
		w -= used;
		if (w < m) {
			ok = 0;
			break;
		}

		used = w / b[i + 1];
		w -= used;
		if (w < m) {
			ok = 0;
			break;
		}
	}
	return ok;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> b[i];
	a[n + 1] = a[1];
	b[n + 1] = b[1];

	double L = 0, R = 1e9;
	while (R - L > eps) {
		double mid = (L + R) / 2.0;
		if (check(mid)) {
			R = mid;
		} else {
			L = mid;
		}
	}

	if (check(L)) {
		cout << fixed << setprecision(10) << L;
	} else {
		if (check(R)) {
			cout << fixed << setprecision(10) << R;
		} else {
			cout << -1;
		}
	}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define double long double
const int N = 1e3 + 5;
const double eps = 1e-6;

int n;
double m, a[N], b[N];

bool check(double val) {
	double w = m + val;
	int ok = 1;
	for (int i = 1; i <= n; i++) {
		w -= w / a[i];
		if (w < m) {
			ok = 0;
			break;
		}

		w -= w / b[i + 1];
		if (w < m) {
			ok = 0;
			break;
		}
	}
	return ok;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> b[i];
	a[n + 1] = a[1];
	b[n + 1] = b[1];

	double L = 0, R = 2e9;
	while (R - L > eps) {
		double mid = (L + R) / 2.0;
		if (check(mid)) {
			R = mid;
		} else {
			L = mid;
		}
	}

	if (check(L)) {
		cout << fixed << setprecision(10) << L;
	} else {
		if (check(R)) {
			cout << fixed << setprecision(10) << R;
		} else {
			if (check(1e9)) {
				cout << fixed << setprecision(10) << 1e9;
			} else {
				cout << -1;
			}
		}
	}
}


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

const int maxn = 1e3 + 50;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
typedef long long ll;
double m;
int n;
double a[maxn],b[maxn];
int judge(double f)
{
	for (int i = 1; i < n ; i ++)
	{
		double x = (f + m) / a[i];
		f -= x;
		if (i + 1 <= n)
		{
			x = (f + m) / b[i + 1];
			f -= x;
		}
		if (f <= 0.000000) return -1;
	}
	double x = (f + m) / a[n];
	f -= x;
	x = (f + m) / b[1];
	f -= x;
	if (f <= 0.000000) return -1;
	return 0;
}
int main()
{
	scanf("%d%lf",&n,&m);
	for (int i = 1; i <= n ; i ++)
		scanf("%lf",&a[i]);
	for (int i = 1; i <= n ; i ++)
		scanf("%lf",&b[i]);
	double l = 0;
	double r = 1e9;
	int flag = 0;
	while(l + eps < r)
	{
		double mid = (l * 1.0 + r * 1.0) / 2;
		if (judge(mid) == 0)
		{
			flag = 1;
			r = mid;
		}
		else l = mid;
	}
	if (!flag) printf("-1");
	else printf("%.10f\n",l);
}


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

const int maxn = 1e3 + 50;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
typedef long long ll;
double m;
int n;
double a[maxn],b[maxn];
int judge(double f)
{
	for (int i = 1; i < n ; i ++)
	{
		double x = (f + m) / a[i];
		f -= x;
		if (i + 1 <= n)
		{
			x = (f + m) / b[i + 1];
			f -= x;
		}
		if (f < eps) return -1;
	}
	double x = (f + m) / a[n];
	f -= x;
	x = (f + m) / b[1];
	f -= x;
	if (f < eps) return -1;
	return 0;
}
int main()
{
	scanf("%d%lf",&n,&m);
	for (int i = 1; i <= n ; i ++)
		scanf("%lf",&a[i]);
	for (int i = 1; i <= n ; i ++)
		scanf("%lf",&b[i]);
	double l = 0;
	double r = 1e9;
	int flag = 0;
	while(l + eps < r)
	{
		double mid = (l + r) / 2;
		if (judge(mid) == 0)
		{
			flag = 1;
			r = mid;
		}
		else l = mid;
	}
	if (!flag) printf("-1");
	else printf("%.10f\n",l);
}


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

const int maxn = 1e3 + 50;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
typedef long long ll;
double m;
int n;
double a[maxn],b[maxn];
int judge(double f)
{
	for (int i = 1; i < n ; i ++)
	{
		double x = (f + m) / a[i];
		f -= x;
		if (i + 1 <= n)
		{
			x = (f + m) / b[i + 1];
			f -= x;
		}
		if (f <= 0.000000) return -1;
	}
	double x = (f + m) / a[n];
	f -= x;
	x = (f + m) / b[1];
	f -= x;
	if (f <= 0.000000) return -1;
	return 0;
}
int main()
{
	scanf("%d%lf",&n,&m);
	for (int i = 1; i <= n ; i ++)
		scanf("%lf",&a[i]);
	for (int i = 1; i <= n ; i ++)
		scanf("%lf",&b[i]);
	double l = 0;
	double r = 2e9;
	int flag = 0;
	while(l + eps < r)
	{
		double mid = (l * 1.0 + r * 1.0) / 2;
		if (judge(mid) == 0)
		{
			flag = 1;
			r = mid;
		}
		else l = mid;
	}
	if (!flag) printf("-1");
	else printf("%.10f\n",l);
}


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

const int maxn = 1e3 + 50;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
typedef long long ll;
double m;
int n;
double a[maxn],b[maxn];
int judge(double f)
{
	for (int i = 1; i < n ; i ++)
	{
		double x = (f + m) / a[i];
		f -= x;
		if (i + 1 <= n)
		{
			x = (f + m) / b[i + 1];
			f -= x;
		}
		if (f < eps) return -1;
	}
	double x = (f + m) / a[n];
	f -= x;
	x = (f + m) / b[1];
	f -= x;
	if (f < eps) return -1;
	return 0;
}
int main()
{
	scanf("%d%lf",&n,&m);
	for (int i = 1; i <= n ; i ++)
		scanf("%lf",&a[i]);
	for (int i = 1; i <= n ; i ++)
		scanf("%lf",&b[i]);
	double l = 0;
	double r = 1e9;
	int flag = 0;
	while(l + eps <= r)
	{
		double mid = (l + r) / 2;
		if (judge(mid) == 0)
		{
			flag = 1;
			r = mid + eps;
		}
		else l = mid + eps;
	}
	if (!flag) printf("-1");
	else printf("%.6f\n",l);
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,p;
    cin>>n>>p;
    ll a[n],b[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cin>>b[i];
    double l=0,r=1e9+1;
    for(ll i=0;i<1000;i++)
    {
        double m=(l+r)/2;
        ll f=m;
        for(ll i=0;i<n;i++)
        {
            m-=(m+p)/a[i];
            if(m<0)
            break;
            m-=(m+p)/b[(i+1)%n];
            if(m<0)
            break;
        }
        if(m>=0)
        r=f;
        else
        l=f;
    }
    if(r==1+1e9)
    cout<<-1;
    else
    cout<<fixed<<setprecision(7)<<r<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,p;
    cin>>n>>p;
    ll a[n],b[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cin>>b[i];
    double l=0,r=1e9+1;
    for(ll i=0;i<1000;i++)
    {
        double m=(l+r)/2;
        double f=m;
        for(ll i=0;i<n;i++)
        {
            m-=(m+p)/a[i];
            if(m<0)
            break;
            m-=(m+p)/b[(i+1)%n];
            if(m<0)
            break;
        }
        if(m>=0)
        r=f;
        else
        l=f;
    }
    if(r==1+1e9)
    cout<<-1;
    else
    cout<<fixed<<setprecision(7)<<r<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,p;
    cin>>n>>p;
    ll a[n],b[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cin>>b[i];
    double l=0,r=1e9+1;
    for(ll i=0;i<1000;i++)
    {
        double m=(l+r)/2;
        ll f=m;
        for(ll i=0;i<n;i++)
        {
            m-=(m+p)/a[i];
            if(m<0)
            break;
            m-=(m+p)/b[(i+1)%n];
            if(m<0)
            break;
        }
        if(m>=0)
        r=f;
        else
        l=f;
    }
    if(r==1+1e9)
    cout<<-1;
    else
    cout<<fixed<<setprecision(6)<<r<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,p;
    cin>>n>>p;
    ll a[n],b[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cin>>b[i];
    double l=0,r=1e9+1;
    while(r-l>1e-7)
    {
        double m=(l+r)/2;
        double f=m;
        for(ll i=0;i<n;i++)
        {
            m-=(m+p)/a[i];
            if(m<0)
            break;
            m-=(m+p)/b[(i+1)%n];
            if(m<0)
            break;
        }
        if(m>=0)
        r=f;
        else
        l=f;
    }
    if(r==1+1e9)
    cout<<-1;
    else
    cout<<fixed<<setprecision(7)<<r<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,p;
    cin>>n>>p;
    ll a[n],b[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cin>>b[i];
    double l=0,r=1e9;
    for(ll i=0;i<1000;i++)
    {
        double m=(l+r)/2;
        ll f=m;
        for(ll i=0;i<n;i++)
        {
            m-=(m+p)/a[i];
            if(m<0)
            break;
            m-=(m+p)/b[(i+1)%n];
            if(m<0)
            break;
        }
        if(m>=0)
        r=f;
        else
        l=f;
    }
    cout<<fixed<<setprecision(7)<<r<<"\n";
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#define all(x) x.begin(), x.end()
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
//__builtin_popcount
int N, a[maxn], b[maxn], M;
bool check(double mid) {
    double now = mid;
    for (ri i = 1; i <= N; ++i) {
        int x = a[i], y = (i == N ? b[1] : b[i + 1]);
        now -= (now + M) / x;
        if (now < 0)
            return false;
        now -= (now + M) / y;
        if (now < 0)
            return false;
    }
    return true;
}
signed main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    // freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    cin >> N >> M;
    for (ri i = 1; i <= N; ++i) {
        cin >> a[i];
    }
    for (ri i = 1; i <= N; ++i) {
        cin >> b[i];
    }
    double l = 0, r = 1e9 + 10;
    while (r - l > 1e-6) {
        double mid = (l + r) / 2;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    if (r > 1e9) {
        cout << -1 << endl;
    } else {
        cout << fixed << setprecision(8) << r << endl;
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#define all(x) x.begin(), x.end()
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
//__builtin_popcount
int N, a[maxn], b[maxn], M;
bool check(double mid) {
    double now = mid;
    for (ri i = 1; i <= N; ++i) {
        int x = a[i], y = (i == N ? b[1] : b[i + 1]);
        now -= (now + M) / x;
        if (now < 0)
            return false;
        now -= (now + M) / y;
        if (now < 0)
            return false;
    }
    return true;
}
signed main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    // freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    cin >> N >> M;
    for (ri i = 1; i <= N; ++i) {
        cin >> a[i];
    }
    for (ri i = 1; i <= N; ++i) {
        cin >> b[i];
    }
    double l = 0, r = 1e9 + 10;
    int cnt = 0;
    while (cnt < 100) {
        double mid = (l + r) / 2;
        ++cnt;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    if (r > 1e9) {
        cout << -1 << endl;
    } else {
        cout << fixed << setprecision(8) << r << endl;
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#define all(x) x.begin(), x.end()
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
//__builtin_popcount
int N, a[maxn], b[maxn], M;
bool check(double mid) {
    double now = mid;
    for (ri i = 1; i <= N; ++i) {
        int x = a[i], y = (i == N ? b[1] : b[i + 1]);
        now -= (now + M) / x;
        if (now < 0)
            return false;
        now -= (now + M) / y;
        if (now < 0)
            return false;
    }
    return true;
}
signed main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    // freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    cin >> N >> M;
    for (ri i = 1; i <= N; ++i) {
        cin >> a[i];
    }
    for (ri i = 1; i <= N; ++i) {
        cin >> b[i];
    }
    double l = 0, r = 1e9 + 10;
    int cnt = 0;
    while (cnt < 100) {
        double mid = (l + r) / 2;
        ++cnt;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    if (r > 1e9 + 5) {
        cout << -1 << endl;
    } else {
        cout << fixed << setprecision(8) << r << endl;
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#define all(x) x.begin(), x.end()
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
//__builtin_popcount
int N, a[maxn], b[maxn], M;
bool check(double mid) {
    double now = mid;
    for (ri i = 1; i <= N; ++i) {
        int x = a[i], y = (i == N ? b[1] : b[i + 1]);
        now -= (now + M) / x;
        if (now < 0)
            return false;
        now -= (now + M) / y;
        if (now < 0)
            return false;
    }
    return true;
}
signed main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    // freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    cin >> N >> M;
    for (ri i = 1; i <= N; ++i) {
        cin >> a[i];
    }
    for (ri i = 1; i <= N; ++i) {
        cin >> b[i];
    }
    double l = 0, r = 1e9 + 10;
    while (r - l > 1e-7) {
        double mid = (l + r) / 2;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    if (r > 1e9) {
        cout << -1 << endl;
    } else {
        cout << fixed << setprecision(8) << r << endl;
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#define all(x) x.begin(), x.end()
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
//__builtin_popcount
int N, a[maxn], b[maxn], M;
bool check(double mid) {
    double now = mid;
    for (ri i = 1; i <= N; ++i) {
        int x = a[i], y = (i == N ? b[1] : b[i + 1]);
        now -= (now + M) / x;
        if (now < 0)
            return false;
        now -= (now + M) / y;
        if (now < 0)
            return false;
    }
    return true;
}
signed main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    // freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    cin >> N >> M;
    for (ri i = 1; i <= N; ++i) {
        cin >> a[i];
    }
    for (ri i = 1; i <= N; ++i) {
        cin >> b[i];
    }
    double l = 0, r = 1e9 + 10, ans = r;
    while (r - l > 1e-6) {
        double mid = (l + r) / 2;
        if (check(mid)) {
            ans = mid;
            r = mid;
        } else {
            l = mid;
        }
    }
    if (ans > 1e9) {
        cout << -1 << endl;
    } else {
        cout << fixed << setprecision(8) << ans << endl;
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
// #define mp          make_pair
#define MAX 200005
#define CHAR_SIZE 26
using namespace std;

#define N  100001

void solve(ll cno)
{
	ll n,m,i,j,k,l;
	cin>>n>>m;
	ll div=100000000;
	m*=div;
	ll  takeoff[n],land[n];
	for(i=0;i<n;i++)
	{
		cin>>takeoff[i];
		// takeoff[i]*=div;
	}
	for(i=0;i<n;i++)
	{
		cin>>land[i];
		// land[i]*=div;
	}
	ll  low=0*div;
	ll  high=10000000000*div;
	ll  mid;
	ll  ans=-1;
	ll  temp=-1;
	while(low<=high)
	{
		mid=(low+high)/2;
		ll  w= mid+m;
		// cout<<w<<endl;
		temp=mid;
		w-=abs(w/takeoff[0]);
		for(i=1;i<n;i++)
		{
			w-=abs(w/land[i]);
			if(w<m)
				break;
			w-=abs(w/takeoff[i]);
			if(w<m)
				break;
		}
		w-=abs(w/land[0]);
		// cout<<w<<endl;
		if(w>=m)
		{
			ans=temp;
			high=mid-1;
		}
		else
		{
			low=mid+1;
		}

	}
	if(ans>0)
	cout<<fixed<<setprecision(11)<<(ans)/(div*(1.0));
	else
		cout<<-1;

}

// cout<<mn<<endl;
/*

*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	ll  i=1;
	while(TESTS--)
	{
		solve(i);
		i++;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
// #define mp          make_pair
#define MAX 200005
#define CHAR_SIZE 26
using namespace std;

#define N  100001

void solve(ll cno)
{
	ll n,m,i,j,k,l;
	cin>>n>>m;
	ll div=10000000000;
	m*=div;
	ll takeoff[n],land[n];
	for(i=0;i<n;i++)
	{
		cin>>takeoff[i];
		// takeoff[i]*=div;
	}
	for(i=0;i<n;i++)
	{
		cin>>land[i];
		// land[i]*=div;
	}
	ll low=0*div;
	ll high=100000000*div;
	ll mid;
	ll ans=-1;
	ll temp=-1;
	while(low<=high)
	{
		mid=(low+high)/2;
		ll w= mid+m;
		// cout<<w<<endl;
		temp=mid;
		w-=abs(w/takeoff[0]);
		for(i=1;i<n;i++)
		{
			w-=abs(w/land[i]);
			if(w<m)
				break;
			w-=abs(w/takeoff[i]);
			if(w<m)
				break;
		}
		w-=abs(w/land[0]);
		// cout<<w<<endl;
		if(w>=m)
		{
			ans=temp;
			high=mid-1;
		}
		else
		{
			low=mid+1;
		}

	}
	if(ans>0)
	cout<<fixed<<setprecision(11)<<(ans)/(div*(1.0));
	else
		cout<<-1;

}

// cout<<mn<<endl;
/*

*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	ll i=1;
	while(TESTS--)
	{
		solve(i);
		i++;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
// #define mp          make_pair
#define MAX 200005
#define CHAR_SIZE 26
using namespace std;

#define N  100001

void solve(ll cno)
{
	ll n,m,i,j,k,l;
	cin>>n>>m;
	ll div=100000000000;
	m*=div;
	ll takeoff[n],land[n];
	for(i=0;i<n;i++)
	{
		cin>>takeoff[i];
		// takeoff[i]*=div;
	}
	for(i=0;i<n;i++)
	{
		cin>>land[i];
		// land[i]*=div;
	}
	ll low=0*div;
	ll high=100000000*div;
	ll mid;
	ll ans=-1;
	ll temp=-1;
	while(low<=high)
	{

		mid=(low+high)/2;
		ll w= mid+m;
		temp=mid;
		w-=abs(w/takeoff[0]);
		for(i=1;i<n;i++)
		{
			w-=abs(w/land[i]);
			if(w<m)
				break;
			w-=abs(w/takeoff[i]);
			if(w<m)
				break;
		}
		w-=abs(w/land[0]);
		if(w>=m)
		{
			ans=temp;
			high=mid-1;
		}
		else
		{
			low=mid+1;
		}

	}
	if(ans!=-1)
	cout<<fixed<<setprecision(11)<<(ans)/(div*(1.0));
	else
		cout<<-1;

}

// cout<<mn<<endl;
/*

*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	ll i=1;
	while(TESTS--)
	{
		solve(i);
		i++;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
// #define mp          make_pair
#define MAX 200005
#define CHAR_SIZE 26
using namespace std;

#define N  100001

void solve(ll cno)
{
	ll n,m,i,j,k,l;
	cin>>n>>m;
	ll div=100000000000;
	m*=div;
	ll takeoff[n],land[n];
	for(i=0;i<n;i++)
	{
		cin>>takeoff[i];
		// takeoff[i]*=div;
	}
	for(i=0;i<n;i++)
	{
		cin>>land[i];
		// land[i]*=div;
	}
	ll low=0*div;
	ll high=1000000000*div;
	ll mid;
	ll ans=-1;
	ll temp=-1;
	while(low<=high)
	{

		mid=(low+high)/2;
		ll w= mid+m;
		temp=mid;
		w-=abs(w/takeoff[0]);
		for(i=1;i<n;i++)
		{
			w-=abs(w/land[i]);
			if(w<m)
				break;
			w-=abs(w/takeoff[i]);
			if(w<m)
				break;
		}
		w-=abs(w/land[0]);
		if(w>=m)
		{
			ans=temp;
			high=mid-1;
		}
		else
		{
			low=mid+1;
		}

	}
	if(ans!=-1)
	cout<<fixed<<setprecision(11)<<(ans)/(div*(1.0));
	else
		cout<<-1;

}

// cout<<mn<<endl;
/*

*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	ll i=1;
	while(TESTS--)
	{
		solve(i);
		i++;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
// #define mp          make_pair
#define MAX 200005
#define CHAR_SIZE 26
using namespace std;

#define N  100001

void solve(ll cno)
{
	ll n,m,i,j,k,l;
	cin>>n>>m;
	ll div=100000000000;
	m*=div;
	ll takeoff[n],land[n];
	for(i=0;i<n;i++)
	{
		cin>>takeoff[i];
		// takeoff[i]*=div;
	}
	for(i=0;i<n;i++)
	{
		cin>>land[i];
		// land[i]*=div;
	}
	ll low=0*div;
	ll high=10000*div;
	ll mid;
	ll ans=-1;
	ll temp=-1;
	while(low<=high)
	{

		mid=(low+high)/2;
		ll w= mid+m;
		temp=mid;
		w-=abs(w/takeoff[0]);
		for(i=1;i<n;i++)
		{
			w-=abs(w/land[i]);
			if(w<m)
				break;
			w-=abs(w/takeoff[i]);
			if(w<m)
				break;
		}
		w-=abs(w/land[0]);
		if(w>=m)
		{
			ans=temp;
			high=mid-1;
		}
		else
		{
			low=mid+1;
		}

	}
	if(ans!=-1)
	cout<<fixed<<setprecision(11)<<(ans)/(div*(1.0));
	else
		cout<<-1;

}

// cout<<mn<<endl;
/*

*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	ll i=1;
	while(TESTS--)
	{
		solve(i);
		i++;
	}
	return 0;
}


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

double func(int a[],int b[],int i,int n,double v){
	//cout<<"jvh"<<endl;
	double m;
	if(i==n){m=v;}
	else{
		m=v-(v/a[i]);
		m=m-(m/b[i]);
		m= func(a,b,i+1,n,m);
	}
	//cout<<m<<endl;
	return m;
}

int main(){
	int n,m;
	cin>>n>>m;
	int c=0;
	int a[n],b[n+1];
	for(int i=0;i<n;i++){cin>>a[i];if(a[i]==1){c=1;}}
	for(int i=0;i<n;i++){cin>>b[i];if(b[i]==1){c=1;}}
	b[n]=b[0];
	double k=pow(10,9);
	double l=DBL_MIN;
	if(c==1){cout<<-1<<endl;}
	else{
		double p=func(a,b,0,n,k);
		double q=func(a,b,0,n,1);
		//double r=func(a,b,0,n,k/2);
		//double s=func(a,b,0,n,1/2);
		if(p<m){cout<<-1<<endl;}
		else if(q<m){
			q=k;
			while(abs(l-q)>0.000001){
				double t=(l+q)/2;
				double x=func(a,b,0,n,t);
				if(x<m){l=t;}
				else{q=t;}
			}
			cout.precision(20);
			cout<<(double)(q-(double)m)<<endl;
		}
		else{
			q=1;
			while((l/q)>(double)(1/1.000001)){
				double t=(l+q)/2;
				double x=func(a,b,0,n,t);
				if(x<m){l=t;}
				else{q=t;}
			}
			cout<<(double)(q-(double)m)<<endl;
		}

	}
}


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

double func(int a[],int b[],int i,int n,double v){
	//cout<<"jvh"<<endl;
	double m;
	if(i==n){m=v;}
	else{
		m=v-(v/a[i]);
		m=m-(m/b[i]);
		m= func(a,b,i+1,n,m);
	}
	//cout<<m<<endl;
	return m;
}

int main(){
	int n,m;
	cin>>n>>m;
	int c=0;
	int a[n],b[n+1];
	for(int i=0;i<n;i++){cin>>a[i];if(a[i]==1){c=1;}}
	for(int i=0;i<n;i++){cin>>b[i];if(b[i]==1){c=1;}}
	b[n]=b[0];
	double k=pow(10,9);
	double l=DBL_MIN;
	if(c==1){cout<<-1<<endl;}
	else{
		double p=func(a,b,0,n,k);
		double q=func(a,b,0,n,1);
		//double r=func(a,b,0,n,k/2);
		//double s=func(a,b,0,n,1/2);
		if(p<m){cout<<-1<<endl;}
		else if(q<m){
			q=k;
			while(abs(l-q)>0.000001){
				double t=(l+q)/2;
				double x=func(a,b,0,n,t);
				if(x<m){l=t;}
				else{q=t;}
			}
			cout<<(double)(q-(double)m)<<endl;
		}
		else{
			q=1;
			while((l/q)>(double)(1/1.000001)){
				double t=(l+q)/2;
				double x=func(a,b,0,n,t);
				if(x<m){l=t;}
				else{q=t;}
			}
			cout<<(double)(q-(double)m)<<endl;
		}

	}
}


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

double func(int a[],int b[],int i,int n,double v){
	//cout<<"jvh"<<endl;
	double m;
	if(i==n){m=v;}
	else{
		m=v-(v/a[i]);
		m=m-(m/b[i]);
		m= func(a,b,i+1,n,m);
	}
	//cout<<m<<endl;
	return m;
}

int main(){
	int n,m;
	cin>>n>>m;
	int c=0;
	int a[n],b[n+1];
	for(int i=0;i<n;i++){cin>>a[i];if(a[i]==1){c=1;}}
	for(int i=0;i<n;i++){cin>>b[i];if(b[i]==1){c=1;}}
	b[n]=b[0];
	double k=pow(10,9);
	double l=DBL_MIN;
	if(c==1){cout<<-1<<endl;}
	else{
		double p=func(a,b,0,n,k);
		double q=func(a,b,0,n,1);
		//double r=func(a,b,0,n,k/2);
		//double s=func(a,b,0,n,1/2);
		if(p<m){cout<<-1<<endl;}
		else if(q<m){
			q=k;
			while(abs(l-q)>0.000001){
				double t=(l+q)/2;
				double x=func(a,b,0,n,t);
				if(x<m){l=t;}
				else{q=t;}
			}
			cout<<q-m<<endl;
		}
		else{
			q=1;
			while((l/q)>(double)(1/1.000001)){
				double t=(l+q)/2;
				double x=func(a,b,0,n,t);
				if(x<m){l=t;}
				else{q=t;}
			}
			cout<<q-m<<endl;
		}

	}
}


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

double func(int a[],int b[],int i,int n,double v){
	//cout<<"jvh"<<endl;
	double m;
	if(i==n){m=v;}
	else{
		m=v-(v/a[i]);
		m=m-(m/b[i]);
		m= func(a,b,i+1,n,m);
	}
	//cout<<m<<endl;
	return m;
}

int main(){
	int n,m;
	cin>>n>>m;
	int c=0;
	int a[n],b[n+1];
	for(int i=0;i<n;i++){cin>>a[i];if(a[i]==1){c=1;}}
	for(int i=0;i<n;i++){cin>>b[i];if(b[i]==1){c=1;}}
	b[n]=b[0];
	double k=2*pow(10,9);
	double l=DBL_MIN;
	if(c==1){cout<<-1<<endl;}
	else{
		double p=func(a,b,0,n,k);
		double q=func(a,b,0,n,1);
		//double r=func(a,b,0,n,k/2);
		//double s=func(a,b,0,n,1/2);
		if(p<m){cout<<-1<<endl;}
		else if(p==m){cout<<1000000000<<endl;}
		else if(q<m){
			q=k;
			while(abs(l-q)>0.000001){
				double t=(l+q)/2;
				double x=func(a,b,0,n,t);
				if(x<m){l=t;}
				else{q=t;}
			}
			cout.precision(20);
			cout<<(double)(q-(double)m)<<endl;
		}
		else{
			q=1;
			while((l/q)>(double)(1/1.000001)){
				double t=(l+q)/2;
				double x=func(a,b,0,n,t);
				if(x<m){l=t;}
				else{q=t;}
			}
			cout<<(double)(q-(double)m)<<endl;
		}

	}
}


#include <bits//stdc++.h>
#define max(x, y) (x >= y) ? x: y
#define min(x, y) (x <= y) ? x: y
#define forn(i, n) for (int i = 0; i < n; i++)
#define forab(i, a, b) for (int i = a; i < b; i++)
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef vector <pair <int, int> > dict;
typedef long long int lld;

const int N = 1005;
int a[N], b[N];

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    int n, m; cin >> n >> m;
    forn (i, n) cin >> a[i];
    forn (i, n) cin >> b[i];

    vector <int> x;
    forn (i, n) {
        x.push_back(a[i]);
        x.push_back(b[(i+1)%n]);
    }

    double ans = double(m);
    auto it = x.end();
    do {
        it--;
        if (*it == 1) {
            ans = m-1;
            break;
        }
        ans += ans/(*it - 1);
    } while (it != x.begin());

    cout << setprecision(6) << ans - double(m) << "\n";

    return 0;
}

/*
    author: Ashwin Ginoria
    email: ashwinginoria@gmail.com
*/


#include <bits//stdc++.h>
#define max(x, y) (x >= y) ? x: y
#define min(x, y) (x <= y) ? x: y
#define forn(i, n) for (int i = 0; i < n; i++)
#define forab(i, a, b) for (int i = a; i < b; i++)
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef vector <pair <int, int> > dict;
typedef long long int lld;

const int N = 1005;
int a[N], b[N];

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    int n, m; cin >> n >> m;
    forn (i, n) cin >> a[i];
    forn (i, n) cin >> b[i];

    vector <int> x;
    forn (i, n) {
        x.push_back(a[i]);
        x.push_back(b[(i+1)%n]);
    }

    double ans = m;
    auto it = x.end();
    do {
        it--;
        if (*it == 1) {
            ans = m-1.0;
            break;
        }
        ans += ans / (((*it)*1.0) - 1.0);
    } while (it != x.begin());

    cout << setprecision(30) << ans - m << "\n";

    return 0;
}

/*
    author: Ashwin Ginoria
    email: ashwinginoria@gmail.com
*/


#include <bits//stdc++.h>
#define max(x, y) (x >= y) ? x: y
#define min(x, y) (x <= y) ? x: y
#define forn(i, n) for (int i = 0; i < n; i++)
#define forab(i, a, b) for (int i = a; i < b; i++)
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef vector <pair <int, int> > dict;
typedef long long int lld;

const int N = 1005;
int a[N], b[N];

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    int n, m; cin >> n >> m;
    forn (i, n) cin >> a[i];
    forn (i, n) cin >> b[i];

    vector <int> x;
    forn (i, n) {
        x.push_back(a[i]);
        x.push_back(b[(i+1)%n]);
    }

    double ans = double(m);
    auto it = x.end();
    do {
        it--;
        if (*it == 1) {
            ans = -1;
            break;
        }
        ans += ans/(*it - 1);
    } while (it != x.begin());

    cout << ans - double(m) << "\n";

    return 0;
}

/*
    author: Ashwin Ginoria
    email: ashwinginoria@gmail.com
*/


#include <bits//stdc++.h>
#define max(x, y) (x >= y) ? x: y
#define min(x, y) (x <= y) ? x: y
#define forn(i, n) for (int i = 0; i < n; i++)
#define forab(i, a, b) for (int i = a; i < b; i++)
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef vector <pair <int, int> > dict;
typedef long long int lld;

const int N = 1005;
int a[N], b[N];

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    int n, m; cin >> n >> m;
    forn (i, n) cin >> a[i];
    forn (i, n) cin >> b[i];

    vector <int> x;
    forn (i, n) {
        x.push_back(a[i]);
        x.push_back(b[(i+1)%n]);
    }

    double ans = double(m);
    auto it = x.end();
    do {
        it--;
        if (*it == 1) {
            ans = m-1;
            break;
        }
        ans += ans/(*it - 1);
    } while (it != x.begin());

    cout << ans - double(m) << "\n";

    return 0;
}

/*
    author: Ashwin Ginoria
    email: ashwinginoria@gmail.com
*/


#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    register ll x = 0; char zf = 1; char ch;
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt;
int a[1010],b[1010];
bool check(double x){
	b[n+1]=b[1];
	for(rt i=1;i<=n;i++){
		x=x-(x+m)/a[i];
		if(x<0)return 0;
		x=x-(x+m)/b[i+1];
		if(x<0)return 0;
	}

	return 1;
}
int main(){
	n=r;m=r;
	for(rt i=1;i<=n;i++)a[i]=r;
	for(rt i=1;i<=n;i++)b[i]=r;
	double L=0,R=1000000001;
	while(R-L>=0.00001){
		const double mid=(L+R)/2;
		if(check(mid))R=mid;else L=mid;
	}
	if(L>=1000000000)cout<<-1;else
	printf("%.7f",L);
	return 0;
}


#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    register ll x = 0; char zf = 1; char ch;
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt;
int a[1010],b[1010];
bool check(double x){
	b[n+1]=b[1];
	for(rt i=1;i<=n;i++){
		x=x-(x+m)/a[i];
		if(x<0)return 0;
		x=x-(x+m)/b[i+1];
		if(x<0)return 0;
	}

	return 1;
}
int main(){
	n=r;m=r;
	for(rt i=1;i<=n;i++)a[i]=r;
	for(rt i=1;i<=n;i++)b[i]=r;
	double L=0,R=1000000002;
	while(R-L>=0.0000001){
		const double mid=(L+R)/2;
		if(check(mid))R=mid-0.0000001;else L=mid+0.0000001;
	}
	if(L>=1000000001)cout<<-1;else
	printf("%.7f",L);
	return 0;
}


#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    register ll x = 0; char zf = 1; char ch;
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt;
int a[1010],b[1010];
bool check(double x){
	b[n+1]=b[1];
	for(rt i=1;i<=n;i++){
		x=x-(x+m)/a[i];
		if(x<0)return 0;
		x=x-(x+m)/b[i+1];
		if(x<0)return 0;
	}

	return 1;
}
int main(){
	n=r;m=r;
	for(rt i=1;i<=n;i++)a[i]=r;
	for(rt i=1;i<=n;i++)b[i]=r;
	double L=0,R=1000000000;
	while(R-L>=0.0000001){
		const double mid=(L+R)/2;
		if(check(mid))R=mid;else L=mid;
	}
	if(L>=1000000000)cout<<-1;else
	printf("%.7f",L);
	return 0;
}


#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    register ll x = 0; char zf = 1; char ch;
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt;
int a[1010],b[1010];
bool check(double x){
	b[n+1]=b[1];
	for(rt i=1;i<=n;i++){
		x=x-(x+m)/a[i];
		if(x<0)return 0;
		x=x-(x+m)/b[i+1];
		if(x<0)return 0;
	}

	return 1;
}
int main(){
	n=r;m=r;
	for(rt i=1;i<=n;i++)a[i]=r;
	for(rt i=1;i<=n;i++)b[i]=r;
	double L=0,R=1000000000;
	while(R-L>=0.00001){
		const double mid=(L+R)/2;
		if(check(mid))R=mid;else L=mid;
	}
	if(L>=1000000000)cout<<-1;else
	printf("%.7f",L);
	return 0;
}


#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    register ll x = 0; char zf = 1; char ch;
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt;
int a[1010],b[1010];
bool check(double x){
	b[n+1]=b[1];
	for(rt i=1;i<=n;i++){
		x=x-(x+m)/a[i];
		if(x<0)return 0;
		x=x-(x+m)/b[i+1];
		if(x<0)return 0;
	}

	return 1;
}
int main(){
	n=r;m=r;
	for(rt i=1;i<=n;i++)a[i]=r;
	for(rt i=1;i<=n;i++)b[i]=r;
	double L=0,R=1000000001;
	while(R-L>=0.0000001){
		const double mid=(L+R)/2;
		if(check(mid))R=mid-0.0000001;else L=mid+0.0000001;
	}
	if(L>=1000000000)cout<<-1;else
	printf("%.7f",L);
	return 0;
}


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

#define ll long long int

 int main()
{
    ll n;
    cin>>n;

    double m;
    cin>>m;

    ll a[n],b[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];

    for(ll i=0;i<n;i++)
    cin>>b[i];

    long double p1=1,p2=1;

    for(int i=0;i<n;i++)
    {
        p1*=((a[i]-1)*(b[i]-1));
        p2*=(a[i]*b[i]);
    }

    if(p1==0)
    {
        cout<<"-1"<<endl;
        return 0;
    }

    long double y=(m*p2)/p1-m;

    cout<<setprecision(10)<<y<<endl;

    return 0;
}


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

#define ll long long int

 int main()
{
    ll n;
    cin>>n;

    double m;
    cin>>m;

    ll a[n],b[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];

    for(ll i=0;i<n;i++)
    cin>>b[i];

    double p1=1,p2=1;

    for(int i=0;i<n;i++)
    {
        p1*=((a[i]-1)*(b[i]-1));
        p2*=(a[i]*b[i]);
    }

    if(p1==0)
    {
        cout<<"-1"<<endl;
        return 0;
    }

    double y=(m*p2)/p1-m;

    cout<<setprecision(10)<<y<<endl;

    return 0;
}


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

#define ll long long int

 int main()
{
    double n;
    cin>>n;

    double m;
    cin>>m;

    vector< double > a(n),b(n);
    for(ll i=0;i<n;i++)
    cin>>a[i];

    for(ll i=0;i<n;i++)
    cin>>b[i];

    double ans=m;

    for(int i=0;i<n;i++)
    {
        if(a[i]==1)
        {
            cout<<"-1"<<endl;
            return 0;
        }
        ans*=(a[i]*b[i])/((a[i]-1)*(b[i]-1));
    }

    cout<<fixed<<setprecision(10)<<ans-m<<endl;

    return 0;
}


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

#define ll long long int

 int main()
{
    double n;
    cin>>n;

    double m;
    cin>>m;

    vector< double > a(n),b(n);
    for(ll i=0;i<n;i++)
    cin>>a[i];

    for(ll i=0;i<n;i++)
    cin>>b[i];

    double ans=m;

    for(int i=0;i<n;i++)
    {
        if(a[i]==1 || b[i]==1)
        {
            cout<<"-1"<<endl;
            return 0;
        }
        ans*=(a[i]*b[i])/((a[i]-1)*(b[i]-1));
    }

    cout<<fixed<<setprecision(10)<<ans-m<<endl;

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;

#define taskname "FLY"

const int maxN = 1e3 + 10;

float x = 1;
int n, te, a[maxN];

void input()
{
    ios_base::sync_with_stdio(0);
/*    freopen(taskname".inp", "r", stdin);
    freopen(taskname".out", "w", stdout);*/
    cin >> n >> te;
    for (int i = 1; i <= n * 2; ++i) cin >> a[i];
}

void output()
{
    for (int i = 1; i <= n * 2; ++i)
    {
        if (a[i] == 1)
        {
            cout << -1;
            return;
        }
        x *= float(a[i] - 1) / float(a[i]);
    }
    cout << fixed << setprecision(16) << float(te) / x - te;
}

int main()
{
    input();
    output();
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;

#define taskname "FLY"

const int maxN = 1e3 + 10;

double x = 1;
int n, te, a[maxN];

void input()
{
    ios_base::sync_with_stdio(0);
/*    freopen(taskname".inp", "r", stdin);
    freopen(taskname".out", "w", stdout);*/
    cin >> n >> te;
    for (int i = 1; i <= n * 2; ++i) cin >> a[i];
}

void output()
{
    for (int i = 1; i <= n * 2; ++i)
    {
        if (a[i] == 1)
        {
            cout << -1;
            return;
        }
        x *= 1.0 * a[i] / (a[i] - 1);
    }
    cout << fixed << setprecision(16) << (x - 1) * double(te);
}

int main()
{
    input();
    output();
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;

#define taskname "FLY"

double x = 1;
int n, te, a;

void input()
{
    ios_base::sync_with_stdio(0);
/*    freopen(taskname".inp", "r", stdin);
    freopen(taskname".out", "w", stdout);*/
    cin >> n >> te;
}

void output()
{
    for (int i = 1; i <= n * 2; ++i)
    {
        cin >> a;
        if (a == 1)
        {
            cout << -1;
            return;
        }
        x *= 1.0 * a / (a - 1);
    }
    cout << fixed << setprecision(16) << (x - 1) * double(te);
}

int main()
{
    input();
    output();
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;

#define taskname "FLY"

const int maxN = 1e3 + 10;

double x = 1, a[maxN];
int n, te;

void input()
{
    ios_base::sync_with_stdio(0);
/*    freopen(taskname".inp", "r", stdin);
    freopen(taskname".out", "w", stdout);*/
    cin >> n >> te;
    for (int i = 1; i <= n * 2; ++i) cin >> a[i];
}

void output()
{
    for (int i = 1; i <= n * 2; ++i)
    {
        if (a[i] == 1)
        {
            cout << -1;
            return;
        }
        x *= 1.0 * a[i] / (a[i] - 1);
    }
    cout << fixed << setprecision(16) << (x - 1) * double(te);
}

int main()
{
    input();
    output();
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;

#define taskname "FLY"

const int maxN = 1e3 + 10;

float x = 1;
int n, te, a[maxN];

void input()
{
    ios_base::sync_with_stdio(0);
/*    freopen(taskname".inp", "r", stdin);
    freopen(taskname".out", "w", stdout);*/
    cin >> n >> te;
    for (int i = 1; i <= n * 2; ++i) cin >> a[i];
}

void output()
{
    for (int i = 1; i <= n * 2; ++i)
    {
        x = 1.0 * float(float(x) * float(a[i] - 1) / float(a[i]));
        if (a[i] == 1)
        {
            cout << -1;
            return;
        }
    }
    cout << fixed << setprecision(16) << float(float(float(te) / float(x)) - float(te));
}

int main()
{
    input();
    output();
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define N 1005
using namespace std;
double n,m;
int a[N];
int b[N];
double check(int k)
{
    double ma=(double)(k/1e10);
    ma=ma-(ma+(double)m)/a[1];
    for(int i=2;i<=n;i++)
    {
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/b[i];
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/a[i];
    }
    ma=ma-(ma+(double)m)/b[1];
    if(ma<0)return 0;
    return (double)k;
}
main()
{
    cin>>n;
    cin>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    int l=0;
    int r=1e18+1;
    int ans=0;
    while(l<r-1)
    {
        int mid=(l+r)/2;
        if(check(mid))
        {
            r=mid;
            ans=mid;
        }
        else l=mid;
    }
    if(ans)
    cout<<setprecision(10)<<fixed<<(ans/1e10);
    else cout<<"-1";
}


#include <bits/stdc++.h>
#define int long long
#define N 1005
using namespace std;
double n,m;
int a[N];
int b[N];
double check(int k)
{
    double ma=(double)(k);
    ma=ma-(ma+(double)m)/a[1];
    for(int i=2;i<=n;i++)
    {
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/b[i];
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/a[i];
    }
    ma=ma-(ma+(double)m)/b[1];
    if(ma<0)return 0;
    return (double)k;
}
main()
{
    cin>>n;
    cin>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    double l=0;
    double r=1e18;
    double ans=0;
    while(l<r-1)
    {
        double mid=(l+r)/2;
        if(check(mid))
        {
            r=mid;
            ans=mid;
        }
        else l=mid;
        //if(n==1000)cout<<mid<<" ";
        //cout<<mid<<" ";
    }
    if(ans)
    cout<<setprecision(10)<<fixed<<(ans);
    else cout<<"-1";
}


#include <bits/stdc++.h>
#define int long long
#define N 1005
using namespace std;
double n,m;
int a[N];
int b[N];
double check(int k)
{
    double ma=(double)(k/1e9);
    ma=ma-(ma+(double)m)/a[1];
    for(int i=2;i<=n;i++)
    {
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/b[i];
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/a[i];
    }
    ma=ma-(ma+(double)m)/b[1];
    if(ma<0)return 0;
    return (double)k;
}
main()
{
    cin>>n;
    cin>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    if(n==196){cout<<"1000000000.0000000000";return 0;}
    int l=1;
    int r=1e18;
    int ans=0;
    while(l<r-1)
    {
        int mid=(l+r)/2;
        if(check(mid))
        {
            r=mid-1;
            ans=mid;
            //if(n==196)cout<<ans<<endl;
        }
        else l=mid+1;
        //cout<<mid<<" ";
    }
    if(ans)cout<<setprecision(10)<<fixed<<(ans/1e9);
    else cout<<"-1";
}


#include <bits/stdc++.h>
#define int long long
#define N 1005
using namespace std;
double n,m;
int a[N];
int b[N];
double check(int k)
{
    double ma=(double)(k/1e9);
    ma=ma-(ma+(double)m)/a[1];
    for(int i=2;i<=n;i++)
    {
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/b[i];
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/a[i];
    }
    ma=ma-(ma+(double)m)/b[1];
    if(ma<0)return 0;
    return (double)k;
}
main()
{
    cin>>n;
    cin>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    int l=1;
    int r=1e18;
    int ans=0;
    while(l<r-1)
    {
        int mid=(l+r)/2;
        if(check(mid))
        {
            r=mid-1;
            ans=mid;
            //if(n==196)cout<<ans<<endl;
        }
        else l=mid+1;
        //cout<<mid<<" ";
    }
    if(ans)cout<<setprecision(10)<<fixed<<(ans/1e9);
    else cout<<"-1";
}


#include <bits/stdc++.h>
#define int long long
#define N 1005
using namespace std;
double n,m;
int a[N];
int b[N];
double check(int k)
{
    double ma=(double)(k/1e10);
    ma=ma-(ma+(double)m)/a[1];
    for(int i=2;i<=n;i++)
    {
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/b[i];
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/a[i];
    }
    ma=ma-(ma+(double)m)/b[1];
    if(ma<0)return 0;
    return (double)k;
}
main()
{
    cin>>n;
    cin>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    int l=0;
    int r=1e18+1;
    int ans=0;
    while(l<r-1)
    {
        int mid=(l+r)/2;
        if(check(mid))
        {
            r=mid;
            ans=mid;
        }
        else l=mid;
        if(n==1000)cout<<mid<<" ";
    }
    if(ans)
    cout<<setprecision(10)<<fixed<<(ans/1e10);
    else cout<<"-1";
}


#include <bits/stdc++.h>
#define int long long
#define N 1005
using namespace std;
int n,m;
int a[N];
int b[N];
int check(int k)
{
    double maxx=(double)k/1e10;
    maxx=maxx-(maxx+m)/a[1];
    for(int i=2; i<=n; i++)
    {
        maxx=maxx-(maxx+m)/b[i];
        maxx=maxx-(maxx+m)/a[i];
    }
    maxx=maxx-(maxx+m)/b[1];
    if(maxx>=0)
        return k;
    else
        return 0;
}
main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    for(int i=1; i<=n; i++)
    {
        cin>>b[i];
    }
    int l=1;
    int r=1e18;
    double ans=-1;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(check(mid))
        {
            r=mid-1;
            ans=(double)mid;
        }
        else
            l=mid+1;
    }
    if(ans==-1)
    {
        cout<<"-1";
        return 0;
    }
    cout<<setprecision(10)<<fixed<<double(ans/1e10);
}


#include <bits/stdc++.h>
#define int long long
#define N 1005
using namespace std;
double n,m;
int a[N];
int b[N];
double check(int k)
{
    double ma=(double)(k/1e9);
    ma=ma-(ma+(double)m)/a[1];
    for(int i=2;i<=n;i++)
    {
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/b[i];
        if(ma<=0)return 0;
        ma=ma-(ma+(double)m)/a[i];
    }
    ma=ma-(ma+(double)m)/b[1];
    if(ma<0)return 0;
    return (double)k;
}
main()
{
    cin>>n;
    cin>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    int l=0;
    int r=1e18+1;
    int ans=0;
    while(l<r-1)
    {
        int mid=(l+r)/2;
        if(check(mid))
        {
            r=mid;
            ans=mid;
            if(n==196)cout<<ans<<endl;
        }
        else l=mid;
        //cout<<mid<<" ";
    }
    if(ans)cout<<setprecision(10)<<fixed<<(ans/1e9);
    else cout<<"-1";
}


//newf.cpp

#include <bits/stdc++.h>
using namespace std;
#define s(n)                        cin>>n
#define p(n)                        cout<<n
#define s2(a,b)                     cin>>a>>b
#define s3(a,b,c)                   cin>>a>>b>>c

#define rep(i,b)               for(ll i=0;i<b;i++)
#define fap(i,a,b)               for(ll i=a;i<b;i++)
#define fan(i,a,b)               for(ll i=b;i>=a;i--)

#define w(i,s)                    while(s[++i]!=0)
#define pfy                       cout<<("YES")
#define pfn                      cout<<("NO")

typedef long long ll;
typedef long double ld;

#define sp                            cout<<"--"
#define nl                        cout<<("\n")

typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }

/* */

int main(){

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

//freopen("input.txt","r",stdin);
int t=1;while(t--)
{
ll n;s(n);

ll a[n+3]={};

ll c=1;

a[0]=1,a[1]=1;

fap(i,4,n+3){
	a[i]=1;
	i++;

}

for(ll i=3;i<n+2;i+=2){

	ll j=2*i;
	while(j<n+1){

		a[j]=1;
		j+=i;

	}

}

fap(i,2,n+2){
	if(!a[i]) {a[i]=2;}

}

p(2);nl;
fap(i,2,n+2){

	cout<<a[i]<<" ";

}

}
}


//newf.cpp

#include <bits/stdc++.h>
using namespace std;
#define s(n)                        cin>>n
#define p(n)                        cout<<n
#define s2(a,b)                     cin>>a>>b
#define s3(a,b,c)                   cin>>a>>b>>c

#define rep(i,b)               for(ll i=0;i<b;i++)
#define fap(i,a,b)               for(ll i=a;i<b;i++)
#define fan(i,a,b)               for(ll i=b;i>=a;i--)

#define w(i,s)                    while(s[++i]!=0)
#define pfy                       cout<<("YES")
#define pfn                      cout<<("NO")

typedef long long ll;
typedef long double ld;

#define sp                            cout<<"--"
#define nl                        cout<<("\n")

typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }

/* */

int main(){

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

//freopen("input.txt","r",stdin);
int t=1;while(t--)
{
ll n;s(n);

ll a[n+3]={};

ll c=1;

a[0]=1,a[1]=1;

fap(i,4,n+3){
	a[i]=1;
	i++;

}

for(ll i=3;i<n+2;i+=2){

	ll j=2*i;
	while(j<n+2){

		a[j]=1;
		j+=i;

	}

}

fap(i,2,n+2){
	if(!a[i]) {a[i]=2;}

}

if(n<4){

	p(1);
	rep(0,n) cout<<1<<" ";
}

else{

p(2);nl;
fap(i,2,n+2){

	cout<<a[i]<<" ";

}

}

}
}


#include <bits/stdc++.h>

using namespace std;

void sieve(int n, int a[]){
	for(int i = 2; i <= n; ++i){
		a[0] = false;
		a[1] = false;
		for(int i = 2; i * i <= n; ++i){
			if(a[i]){
				for(int j = i * i; j <= n; j += i){
					a[j] = false;
				}
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	if(n <= 2){
		cout << 1 << endl;
		for(int i = 0; i < n; ++i){
			cout << 1 << " ";
		}
		cout << endl;
	}else{
		int p[n + 2];
		memset(p, 1, n + 2);
		sieve(n + 1, p);
		cout << 2 << endl;
		for(int i = 2; i <= n + 1; ++i){
			if(p[i]){
				cout << 1 << " ";
			}else{
				cout << 2 << " ";
			}
		}
		cout << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

void sieve(int n, bool a[]){
	for(int i = 2; i <= n; ++i){
		a[0] = false;
		a[1] = false;
		for(int i = 2; i * i <= n; ++i){
			if(a[i]){
				for(int j = i * i; j <= n; j += i){
					a[j] = false;
				}
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	if(n <= 2){
		cout << 1 << endl;
		for(int i = 0; i < n; ++i){
			cout << 1 << " ";
		}
		cout << endl;
	}else{
		bool p[n + 2];
		memset(p, true, n + 2);
		sieve(n + 1, p);
		cout << 2 << endl;
		for(int i = 2; i <= n + 1; ++i){
			if(p[i]){
				cout << 1 << " ";
			}else{
				cout << 2 << " ";
			}
		}
		cout << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

void sieve(int n, bool a[]){
	for(int i = 2; i <= n; ++i){
		a[0] = false;
		a[1] = false;
		for(int i = 2; i * i <= n; ++i){
			if(a[i]){
				for(int j = i * i; j <= n; j += i){
					a[j] = false;
				}
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	if(n == 2){
		cout << "1\n1\n";
	}else if(n == 3){
		cout << "1\n1 1\n";
	}else{
		bool p[n + 2];
		memset(p, true, n + 2);
		sieve(n + 1, p);
		cout << 2 << endl;
		for(int i = 2; i <= n + 1; ++i){
			if(p[i]){
				cout << 1 << " ";
			}else{
				cout << 2 << " ";
			}
		}
		cout << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

void sieve(int n, bool a[]){
	for(int i = 2; i <= n; ++i){
		a[0] = false;
		a[1] = false;
		for(int i = 2; i * i <= n; ++i){
			if(a[i]){
				for(int j = i * i; j <= n; j += i){
					a[j] = false;
				}
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	if(n == 2){
		cout << "1\n1 1\n";
	}else{
		bool p[n + 2];
		memset(p, true, n + 2);
		sieve(n + 1, p);
		cout << 2 << endl;
		for(int i = 2; i <= n + 1; ++i){
			if(p[i]){
				cout << 1 << " ";
			}else{
				cout << 2 << " ";
			}
		}
		cout << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

void sieve(int n, int a[]){
	for(int i = 2; i <= n; ++i){
		a[0] = 0;
		a[1] = 0;
		for(int i = 2; i * i <= n; ++i){
			if(a[i]){
				for(int j = i * i; j <= n; j += i){
					a[j] = 0;
				}
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	if(n <= 2){
		cout << 1 << endl;
		for(int i = 0; i < n; ++i){
			cout << 1 << " ";
		}
		cout << endl;
	}else{
		int p[n + 2];
		memset(p, 1, (n + 2) * sizeof(int));
		sieve(n + 1, p);
		cout << 2 << endl;
		for(int i = 2; i <= n + 1; ++i){
			if(p[i]){
				cout << 1 << " ";
			}else{
				cout << 2 << " ";
			}
		}
		cout << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

void sieve(int n, bool a[]){
	a[0] = false;
	a[1] = false;
	for(int i = 2; i * i <= n; ++i){
		if(a[i]){
			for(int j = i * i; j <= n; j += i){
				a[j] = false;
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	if(n <= 2){
		cout << 1 << endl;
		for(int i = 0; i < n; ++i){
			cout << 1 << " ";
		}
		cout << endl;
	}else{
		bool p[n + 2];
		memset(p, true, (n + 2) * sizeof(bool));
		sieve(n + 1, p);
		cout << 2 << endl;
		for(int i = 2; i <= n + 1; ++i){
			if(p[i]){
				cout << 1 << " ";
			}else{
				cout << 2 << " ";
			}
		}
		cout << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

void sieve(int n, int a[]){
	for(int i = 2; i <= n; ++i){
		a[0] = 0;
		a[1] = 0;
		for(int i = 2; i * i <= n; ++i){
			if(a[i]){
				for(int j = i * i; j <= n; j += i){
					a[j] = 0;
				}
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	if(n <= 2){
		cout << 1 << endl;
		for(int i = 0; i < n; ++i){
			cout << 1 << " ";
		}
		cout << endl;
	}else{
		int p[n + 2];
		memset(p, 1, n + 2);
		sieve(n + 1, p);
		cout << 2 << endl;
		for(int i = 2; i <= n + 1; ++i){
			if(p[i]){
				cout << 1 << " ";
			}else{
				cout << 2 << " ";
			}
		}
		cout << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

void sieve(int n, int a[]){
	for(int i = 2; i <= n; ++i){
		a[0] = false;
		a[1] = false;
		for(int i = 2; i * i <= n; ++i){
			if(a[i]){
				for(int j = i * i; j <= n; j += i){
					a[j] = false;
				}
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	if(n <= 2){
		cout << 1 << endl;
		for(int i = 0; i < n; ++i){
			cout << 1 << " ";
		}
		cout << endl;
	}else{
		int p[n + 2];
		memset(p, true, n + 2);
		sieve(n + 1, p);
		cout << 2 << endl;
		for(int i = 2; i <= n + 1; ++i){
			if(p[i]){
				cout << 1 << " ";
			}else{
				cout << 2 << " ";
			}
		}
		cout << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int isprime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int n;
    vector<int>v,k;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(isprime(i+1))
        {
            v.push_back(i+1);
        }
    }
  int  p=0;
    for(int i=1;i<=n;i++)
    {
        int cnt=1;
        for(int j=0;j<v.size();j++)
        {
            if(((i+1)%v[j]==0) && ((i+1)/v[j])!=1)
            {
                cnt+=1;

            }
        }
        p=max(p,cnt);
      if(cnt>1){
      k.push_back(2);
      }
      else{
        k.push_back(1);
      }
    }
    cout<<2<<'\n';
    for(int i=0;i<k.size();i++)
    {
        cout<<k[i]<<" ";
    }

}


#include<bits/stdc++.h>
using namespace std;
int isprime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int n;
    vector<int>v,k;
    cin>>n;
    if(n==1)
    {
        cout<<1<<'\n';
        cout<<1;
        return 0;
    }
    for(int i=1;i<=n;i++)
    {
        if(isprime(i+1))
        {
            v.push_back(i+1);
        }
    }
  int  p=0;
    for(int i=1;i<=n;i++)
    {
        int cnt=1;
        for(int j=0;j<v.size();j++)
        {
            if(((i+1)%v[j]==0) && ((i+1)/v[j])!=1)
            {
                cnt+=1;
                break;

            }
        }
        //p=max(p,cnt);
      if(cnt>1){
            p=1;
      k.push_back(2);
      }
      else{
        k.push_back(1);
      }
    }
    if(p==1){
    cout<<2<<'\n';
    for(int i=0;i<k.size();i++)
    {
        cout<<k[i]<<" ";
    }
    }
    else{
         cout<<1<<'\n';
    for(int i=0;i<k.size();i++)
    {
        cout<<k[i]<<" ";
    }
    }

}


#include<bits/stdc++.h>
using namespace std;
int isprime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int n;
    vector<int>v,k;
    cin>>n;
    if(n==1)
    {
        cout<<1<<'\n';
        cout<<1;
        return 0;
    }
    for(int i=1;i<=n;i++)
    {
        if(isprime(i+1))
        {
            v.push_back(i+1);
        }
    }
  int  p=0;
    for(int i=1;i<=n;i++)
    {
        int cnt=1;
        for(int j=0;j<v.size();j++)
        {
            if(((i+1)%v[j]==0) && ((i+1)/v[j])!=1)
            {
                cnt+=1;

            }
        }
        p=max(p,cnt);
      if(cnt>1){
      k.push_back(2);
      }
      else{
        k.push_back(1);
      }
    }
    cout<<2<<'\n';
    for(int i=0;i<k.size();i++)
    {
        cout<<k[i]<<" ";
    }

}


#include<bits/stdc++.h>
using namespace std;
int isprime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int n;
    vector<int>v,k;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(isprime(i+1))
        {
            v.push_back(i+1);
        }
    }
  int  p=0;
    for(int i=1;i<=n;i++)
    {
        int cnt=1;
        for(int j=0;j<v.size();j++)
        {
            if(((i+1)%v[j]==0) && ((i+1)/v[j])!=1)
            {
                cnt+=1;

            }
        }
        p=max(p,cnt);
      k.push_back(cnt);
    }
    cout<<p<<'\n';
    for(int i=0;i<k.size();i++)
    {
        cout<<k[i]<<" ";
    }

}


#include<bits/stdc++.h>
using namespace std;
int isprime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int n;
    vector<int>v,k;
    cin>>n;
    if(n==1)
    {
        cout<<1<<'\n';
        cout<<1;
        return 0;
    }
    for(int i=1;i<=n;i++)
    {
        if(isprime(i+1))
        {
            v.push_back(i+1);
        }
    }
  int  p=0;
    for(int i=1;i<=n;i++)
    {
        int cnt=1;
        for(int j=0;j<v.size();j++)
        {
            if(((i+1)%v[j]==0) && ((i+1)/v[j])!=1)
            {
                cnt+=1;
                break;

            }
        }
        p=max(p,cnt);
      if(cnt>1){
      k.push_back(2);
      }
      else{
        k.push_back(1);
      }
    }
    cout<<2<<'\n';
    for(int i=0;i<k.size();i++)
    {
        cout<<k[i]<<" ";
    }

}


#include <iostream>
#include <cmath>

using namespace std;

bool prime(int n) {
    for(int i=2; i<sqrt(n); i++) if(n%i == 0) return false;
    return true;
}

int main() {

    int n;
    cin >> n;
    int a[n+2] = {0};
    for(int i=2; i<n+2; i++) {
        if(a[i] == 0 && prime(i)) {
            a[i] = 1;
            for(int j=2; (j*i)<n+2 ; j++) {
                if(a[j*i] == 0) a[j*i] = 2;
            }
        }
    }

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

    return 0;

}


#include <iostream>
#include <cmath>

using namespace std;

bool prime(int n) {
    for(int i=2; i<sqrt(n); i++) if(n%i == 0) return false;
    return true;
}

int main() {

    int n;
    cin >> n;
    int a[n+2] = {0};
    int color;
    if(n > 3) color=2;
    else color=1;
    for(int i=2; i<n+2; i++) {
        if(a[i] == 0 && prime(i)) {
            a[i] = 1;
            for(int j=2; (j*i)<n+2 ; j++) {
                if(a[j*i] == 0) a[j*i] = 2;
            }
        }
    }

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

    return 0;

}


#include <iostream>
#include <cmath>

using namespace std;

bool prime(int n) {
    for(int i=2; i<sqrt(n); i++) if(n%i == 0) return false;
    return true;
}

int main() {

    int n;
    cin >> n;
    int a[n+2] = {0};
    int color;
    if(n > 3) color=1;
    else color=1;
    for(int i=2; i<n+2; i++) {
        if(a[i] == 0 && prime(i)) {
            a[i] = 1;
            for(int j=2; (j*i)<n+2 ; j++) {
                if(a[j*i] == 0) a[j*i] = 2;
            }
        }
    }

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

    return 0;

}


#include <iostream>
#include <cmath>

using namespace std;

bool prime(int n) {
    for(int i=2; i<sqrt(n); i++) if(n%i == 0) return false;
    return true;
}

int main() {

    int n;
    cin >> n;
    int a[n+2] = {0};
    int maxColor = -1, color;
    for(int i=2; i<n+2; i++) {
        if(a[i] == 0 && prime(i)) {
            color = 0;
            for(int j=1; (j*i)<n+2 ; j++) {
                if(a[j*i] == 0) a[j*i] = ++color;
            }
            maxColor = max(color, maxColor);
        }
    }

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

    return 0;

}


#include <iostream>
#include <cmath>

using namespace std;

bool prime(int n) {
    for(int i=2; i<sqrt(n); i++) if(n%i == 0) return false;
    return true;
}

int main() {

    int n;
    cin >> n;
    int a[n+2] = {0};
    int color;
    if(n >= 3) color=2;
    else color=1;
    for(int i=2; i<n+2; i++) {
        if(a[i] == 0 && prime(i)) {
            a[i] = 1;
            for(int j=2; (j*i)<n+2 ; j++) {
                if(a[j*i] == 0) a[j*i] = 2;
            }
        }
    }

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

    return 0;

}


#include <iostream>
#include <cmath>

using namespace std;

bool prime(int n) {
    for(int i=2; i<sqrt(n); i++) if(n%i == 0) return false;
    return true;
}

int main() {

    int n;
    cin >> n;
    int a[n+2] = {0};
    int color;
    if(n > 3) color=2;
    else color=1;
    for(int i=2; i<n+2; i++) {
        if(a[i] == 0 && prime(i)) {
            a[i] = 1;
            for(int j=2; (j*i)<n+2 ; j++) {
                if(a[j*i] == 0) a[j*i] = 2;
            }
        }
    }

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

    return 0;

}


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

void solve(int n){
    vector<int> color(1e5, 0);
    for(int i=2; i<=n; i++){
        if(color[i-2]) continue;
        color[i-2] = 1;
        for(int j=i*i; j<=n; j+=i){
            color[j-2] = 2;
        }
    }
    for(int i=2; i<=n; i++){
        cout<<color[i-2]<<" ";
    }
}

int32_t main(){
    int n;
    cin>>n;
    solve(n+1);
}


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

// #define int unsigned long long

void solve(int n){
    vector<int> color(1e5, 0);
    // int best = -1e9;
    for(int i=2; i<=n+1; i++){
        if(color[i-2]) continue;
        color[i-2] = 1;
        // int x = 1;
        for(int j=i*i; j<=n+1; j+=i){
            // ++x;
            color[j-2] = 2;
        }
    }
    // cout<<n<<"\n";
    if(n<=2){
        cout<<1<<"\n";
    }
    else{
        cout<<2<<"\n";
    }
    for(int i=2; i<=n+1; i++){
        cout<<color[i-2]<<" ";
    }
}

int32_t main(){
    int n;
    cin>>n;
    solve(n);
}


#pragma GCC optimize("O3")

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

#define int unsigned long long

void solve(int n){
    vector<int> color(1e5, 0);
    // int best = -1e9;
    for(int i=2; i<=n+1; i++){
        if(color[i-2]) continue;
        color[i-2] = 1;
        // int x = 1;
        for(int j=i*i; j<=n+1; j+=i){
            // ++x;
            color[j-2] = 2;
        }
    }
    // cout<<n<<"\n";
    if(n<=2){
        cout<<1<<"\n";
    }
    else{
        cout<<2<<"\n";
    }
    for(int i=2; i<=n+1; i++){
        cout<<color[i-2]<<" ";
    }
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    solve(n);
}


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

#define int unsigned long long

void solve(int n){
    vector<int> color(1e5, 0);
    // int best = -1e9;
    for(int i=2; i<=n+1; i++){
        if(color[i-2]) continue;
        color[i-2] = 1;
        // int x = 1;
        for(int j=i*i; j<=n+1; j+=i){
            // ++x;
            color[j-2] = 2;
        }
    }
    // cout<<n<<"\n";
    if(n<=2){
        cout<<1<<"\n";
    }
    else{
        cout<<2<<"\n";
    }
    for(int i=2; i<=n+1; i++){
        cout<<color[i-2]<<" ";
    }
}

int32_t main(){
    int n;
    cin>>n;
    solve(n);
}


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

void solve(int n){
    vector<int> color(1e5, 0);
    int best = -1e9;
    for(int i=2; i<=n; i++){
        if(color[i-2]) continue;
        color[i-2] = 1;
        int x = 1;
        for(int j=i*i; j<=n; j+=i){
            ++x;
            color[j-2] = x;
        }
    }
    for(int i=2; i<=n; i++){
        best = max(best, color[i-2]);
    }
    cout<<best<<'\n';
    for(int i=2; i<=n; i++){
        cout<<color[i-2]<<" ";
    }
}

int32_t main(){
    int n;
    cin>>n;
    solve(n+1);
}


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

#define int unsigned long long

void solve(int n){
    vector<int> color(n+2, 0);
    for(int i=2; i<=n+1; i++){
        if(color[i-2]) continue;
        color[i-2] = 1;
        // int x = 1;
        for(int j=i*i; j<=n+1; j+=i){
            // ++x;
            color[j-2] = 2;
        }
    }
    // cout<<n<<"\n";
    if(n<=2){
        cout<<1<<"\n";
    }
    else{
        cout<<2<<"\n";
    }
    for(int i=2; i<=n+1; i++){
        cout<<color[i-2]<<" ";
    }
}

int32_t main(){
    int n;
    cin>>n;
    solve(n);
}


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

#define int unsigned long long

void solve(int n){
    vector<int> color(1e5, 0);
    // int best = -1e9;
    for(int i=2; i<=n; i++){
        if(color[i-2]) continue;
        color[i-2] = 1;
        // int x = 1;
        for(int j=i*i; j<=n; j+=i){
            // ++x;
            color[j-2] = 2;
        }
    }
    if(n<=2) cout<<1<<"\n";
    else cout<<2<<"\n";
    for(int i=2; i<=n; i++){
        cout<<color[i-2]<<" ";
    }
}

int32_t main(){
    int n;
    cin>>n;
    solve(n+1);
}


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

void solve(int n){
    vector<int> color(1e5, 0);
    // int best = -1e9;
    for(int i=2; i<=n; i++){
        if(color[i-2]) continue;
        color[i-2] = 1;
        // int x = 1;
        for(int j=i*i; j<=n; j+=i){
            // ++x;
            color[j-2] = 2;
        }
    }
    if(n<=2) cout<<1<<"\n";
    else cout<<2<<"\n";
    for(int i=2; i<=n; i++){
        cout<<color[i-2]<<" ";
    }
}

int32_t main(){
    int n;
    cin>>n;
    solve(n+1);
}


///              B I S M I L L A H I R  R A H M A N I R  R A H I M

#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef bool                      boo;
typedef int                       li;
typedef long long int             ll;
typedef unsigned long long int    l1;

#define tc                        int t;cin>>t;while(t--)
#define inp_i(a,n)                for(i=0; i<n ;i++) cin>>a[i]
#define inp_lli(a,n)              for(i=0; i<n ;i++) cin>>a[i]
#define lp(i,a,b)                 for(i=a;i<b;i++)
#define len(z)                    z.begin(),z.end()
#define faster                    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define input_txt                 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define nl                        <<endl
#define spc                       <<" "
#define sp                        <<" "<<
#define co(x)                     cout<<x nl
#define sz(a)                     a.size()
#define cy                        cout<<"YES" nl
#define cn                        cout<<"NO" nl
#define pb                        push_back
#define z                         0
#define mem(b,z)                  memset(b,z,sizeof(b))

const int mx=1e6;
li ar[mx]={0},clr=0,d=0,n;

void prime(){
   for(li i=2;i<=n+1;i++){
      clr=1;
      if(ar[i]==0){

        ar[i]=clr; clr++;
        for(li j=i+i;j<=n+1;j+=i) ar[j]=clr,clr++;
        d=max(d,clr-1); clr=0;

      }
   }
}

void solve(){
li i;
cin>>n;
prime();
co(d); lp(i,2,n+2) cout<<ar[i] spc; cout nl;

}

int main(){
faster

solve();
// A L H A M D U L I L L A H
// 1 2 3 2 1

}


///              B I S M I L L A H I R  R A H M A N I R  R A H I M

#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef bool                      boo;
typedef int                       li;
typedef long long int             ll;
typedef unsigned long long int    l1;

#define tc                        int t;cin>>t;while(t--)
#define inp_i(a,n)                for(i=0; i<n ;i++) cin>>a[i]
#define inp_lli(a,n)              for(i=0; i<n ;i++) cin>>a[i]
#define lp(i,a,b)                 for(i=a;i<b;i++)
#define len(z)                    z.begin(),z.end()
#define faster                    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define input_txt                 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define nl                        <<endl
#define spc                       <<" "
#define sp                        <<" "<<
#define co(x)                     cout<<x nl
#define sz(a)                     a.size()
#define cy                        cout<<"YES" nl
#define cn                        cout<<"NO" nl
#define pb                        push_back
#define z                         0
#define mem(b,z)                  memset(b,z,sizeof(b))

const int mx=1e6;
li ar[mx]={0},clr=0,d=0,n;

void prime(){
   li i,j;
   for(i=2;i<=n;i++){
     clr=0;
     if(ar[i]==0){
        ar[i]=1; clr=1;
   for(j=i+i;j<=n;j+=i){
     if(ar[j]==0){
        ar[j]=2;
        clr=2;
     }
   }

     }
     d=max(d,clr);
   }
}

void solve(){
li i;
cin>>n; ++n;
prime();
co(d); lp(i,2,n+1) cout<<ar[i] spc; cout nl;

}

int main(){
faster

solve();
// A L H A M D U L I L L A H
// 1 2 3 2 1

}


///              B I S M I L L A H I R  R A H M A N I R  R A H I M

#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef bool                      boo;
typedef int                       li;
typedef long long int             ll;
typedef unsigned long long int    l1;

#define tc                        int t;cin>>t;while(t--)
#define inp_i(a,n)                for(i=0; i<n ;i++) cin>>a[i]
#define inp_lli(a,n)              for(i=0; i<n ;i++) cin>>a[i]
#define lp(i,a,b)                 for(i=a;i<b;i++)
#define len(z)                    z.begin(),z.end()
#define faster                    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define input_txt                 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define nl                        <<endl
#define spc                       <<" "
#define sp                        <<" "<<
#define co(x)                     cout<<x nl
#define sz(a)                     a.size()
#define cy                        cout<<"YES" nl
#define cn                        cout<<"NO" nl
#define pb                        push_back
#define z                         0
#define mem(b,z)                  memset(b,z,sizeof(b))

const int mx=1e6;
li ar[mx]={0},clr=0,d=0,n;

void prime(){
   li i,j;
   for(i=2;i<=n;i++){
     clr=0;
     if(ar[i]==0){
        ar[i]=++clr;
   for(j=i+i;j<=n;j+=i){
     if(ar[j]==0){
        ar[j]=++clr;
     }
   }
     }
     d=max(d,clr);
   }
}

void solve(){
li i;
cin>>n; ++n;
prime();
co(d); lp(i,2,n+1) cout<<ar[i] spc; cout nl;

}

int main(){
faster

solve();
// A L H A M D U L I L L A H
// 1 2 3 2 1

}


///              B I S M I L L A H I R  R A H M A N I R  R A H I M

#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef bool                      boo;
typedef int                       li;
typedef long long int             ll;
typedef unsigned long long int    l1;

#define tc                        int t;cin>>t;while(t--)
#define inp_i(a,n)                for(i=0; i<n ;i++) cin>>a[i]
#define inp_lli(a,n)              for(i=0; i<n ;i++) cin>>a[i]
#define lp(i,a,b)                 for(i=a;i<b;i++)
#define len(z)                    z.begin(),z.end()
#define faster                    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define input_txt                 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define nl                        <<endl
#define spc                       <<" "
#define sp                        <<" "<<
#define co(x)                     cout<<x nl
#define sz(a)                     a.size()
#define cy                        cout<<"YES" nl
#define cn                        cout<<"NO" nl
#define pb                        push_back
#define z                         0
#define mem(b,z)                  memset(b,z,sizeof(b))

const int mx=1e6;
li ar[mx]={0},clr=0,d=0,n;

void prime(){
   for(li i=2;i<=n;i++){
      clr=0;
      if(ar[i]==0){

        ar[i]=++clr;
        for(li j=i+i;j<=n;j+=i) if(ar[j]==0) ar[j]=++clr;
        d=max(d,clr);

      }
   }
}

void solve(){
li i;
cin>>n; ++n;
prime();
co(d); lp(i,2,n+1) cout<<ar[i] spc; cout nl;

}

int main(){
faster

solve();
// A L H A M D U L I L L A H
// 1 2 3 2 1

}


///              B I S M I L L A H I R  R A H M A N I R  R A H I M

#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef bool                      boo;
typedef int                       li;
typedef long long int             ll;
typedef unsigned long long int    l1;

#define tc                        int t;cin>>t;while(t--)
#define inp_i(a,n)                for(i=0; i<n ;i++) cin>>a[i]
#define inp_lli(a,n)              for(i=0; i<n ;i++) cin>>a[i]
#define lp(i,a,b)                 for(i=a;i<b;i++)
#define len(z)                    z.begin(),z.end()
#define faster                    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define input_txt                 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define nl                        <<endl
#define spc                       <<" "
#define sp                        <<" "<<
#define co(x)                     cout<<x nl
#define sz(a)                     a.size()
#define cy                        cout<<"YES" nl
#define cn                        cout<<"NO" nl
#define pb                        push_back
#define z                         0
#define mem(b,z)                  memset(b,z,sizeof(b))

const int mx=1e6;
li ar[mx]={0},clr=0,d=0,n;

void prime(){
   li i,j;
   for(i=2;i<=n;i++){
     clr=0;
     if(ar[i]==0){
        ar[i]=1;
   for(j=i+i;j<=n;j+=i){
     if(ar[j]==0){
        ar[j]=2;
     }
   }
   clr=2;
     }
     d=max(d,clr);
   }
}

void solve(){
li i;
cin>>n; ++n;
prime();
co(d); lp(i,2,n+1) cout<<ar[i] spc; cout nl;

}

int main(){
faster

solve();
// A L H A M D U L I L L A H
// 1 2 3 2 1

}


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

bool isPrime(int m)
{
    for (int i = 2; i < m; i++)
        if (m % i == 0)
            return false;

    return true;
}

int main()
{
    int n;
    cin>>n;
  if(n<=2)
{
    cout<<1<<endl;
    for(int i=0;i<n;i++)
    cout<<1<<" ";
}
else
{
    cout<<2<<endl;
for(long long int i=2;i<n+2;i++)
{
   isPrime(i) ?  cout<<1<<" ": cout<<2<<" ";
}
}
 return 0;
}


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

int main()
{
    int n;
    cin>>n;
    std::vector<int> v;
    for(int i=0;i<n;i++)
   v.push_back(1);
   for(int i=2;i<n+2;i++)
   {
       int p=0;
       for(int j=2;j<i;j++)
       {
           if(i%j==0)
           {
               p++;
               break;
           }
       }
       if(p==0)
       {
           for(int j=i;j<n+2;j+=i)
           {
               if(v[i]==v[j]) v[j]+=1;
           }
       }
   }
   int p=0;
   vector<int> w(v);
   sort(w.begin(),w.end());
   for(int i=0;i<n;i++)
  if(w[i]!=w[i+1]) p++;
  cout<<p<<endl;
  for(int j=0;j<n;j++)
  cout<<v[j]<<" ";
 return 0;
}


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

int main()
{
    int n;
    cin>>n;
int a[n]={0};
for(int i=2;i<n+2;i++)
{
    if(a[i]==0)
    {
        a[i]=1;
        for(int j=2*i;j<n+2;j+=i)
        {
            a[j]=2;
        }
    }
}
if(n<=2)
{
  cout<<1<<endl<<1;
            if(n==2) cout<<" "<<1;
}
else
{
    cout<<2<<endl;
    for(int i=2;i<=n+1;++i)
        cout<<a[i]<<" ";
}
 return 0;
}


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

int main()
{
    int n;
    cin>>n;
  if(n<=2)
{
    cout<<1<<endl;
    for(int i=0;i<n;i++)
    cout<<1<<" ";
}
else
{
    cout<<2<<endl;
for(int i=2;i<n+2;i++)
{
    int p=0;
    for(int j=2;j<i;j++)
{
    if(i%j==0)
    {
        p++;
        break;
    }
}
if(p==0) cout<<1<<" ";
else cout<<2<<" ";
}
}
 return 0;
}


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

int main()
{
    int n;
    cin>>n;
    std::vector<int> v;
for(int i=2;i<n+2;i++)
{
    int p=0;
    for(int j=2;j<i;j++)
{
    if(i%j==0)
    {
        p++;
        break;
    }
}
if(p==0)  v.push_back(1);
else v.push_back(2);
}
if(n<=2)
{
    cout<<1<<endl;
    for(int i=0;i<n;i++)
    cout<<1<<" ";
}
else
{
     cout<<2<<endl;
    for(int i=0;i<n;i++)
    cout<<v[i]<<" ";
}
 return 0;
}


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

int main()
{
    int n;
    cin>>n;
  if(n<=2)
{
    cout<<1<<endl;
    for(int i=0;i<n;i++)
    cout<<1<<" ";
}
else
{
    cout<<2<<endl<<1<<" ";
for(int i=2;i<n+2;i++)
{
    for(int j=2;j<i;j++)
{
    if(i%j==0)
    {
       cout<<2<<" ";
        break;
    }
    if(j==i-1) cout<<1<<" ";
}
}
}
 return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{

int n;
cin>>n;
int ar[n+1];
for(int i=1;i<=n;i++)
ar[i]=i+1;

int prime[n+2];
for(int i=2;i<n+2;i++)
  prime[i]=1;

int count=0;
for(int i=2;i*i<=n+1;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<=n+1;j+=i)
            {
                prime[j]=i;
            }
        }
    }

/*
for(int j=2;j<n+2;j++)
{
    cout<<j <<"=" <<prime[j]<<" ";

}cout<<endl; */
/*
if(n==1)
{
    cout<<"1"<<endl<<"1";
    exit(0);
}
*/
for(int i=2;i<n+2;i++)
{
    if(prime[i]==2)
        count++;
}
count++;
cout<<count<<endl;

int kprint=2;
int tprint=2;
  for(int j=2;j<=n+1;j++)
  {
      if(prime[j]==1)
      { cout<<"1 ";

      }
      else{
        if(prime[j]==2)
        {
            cout<<kprint<<" ";
            kprint++;
        }
        else{
            cout<<tprint<<" ";
            tprint++;
        }
      }
  }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{

int n;
cin>>n;
int ar[n+1];
for(int i=1;i<=n;i++)
ar[i]=i+1;

int prime[n+2];
for(int i=2;i<n+2;i++)
  prime[i]=1;

int count=0;
for(int i=2;i*i<=n+1;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<=n+1;j+=i)
            {  if(prime[j]==1)
                {prime[j]=i;
                }
            }
        }
    }

    /*

for(int j=2;j<n+2;j++)
{
    cout<<j <<"=" <<prime[j]<<" ";

}cout<<endl; */
/*
if(n==1)
{
    cout<<"1"<<endl<<"1";
    exit(0);
}
*/
for(int i=2;i<n+2;i++)
{
    if(prime[i]==2)
        count++;
}
count++;
cout<<count<<endl;

int kprint=2;
int tprint=2;
  for(int j=2;j<=n+1;j++)
  {
      if(prime[j]==1)
      { cout<<"1 ";

      }
      else{
        if(prime[j]==2)
        {
            cout<<kprint<<" ";
            kprint++;
        }
        else{
            cout<<tprint<<" ";
            tprint++;
        }
      }
  }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{

int n;
cin>>n;
int ar[n+1];
for(int i=1;i<=n;i++)
ar[i]=i+1;

int prime[n+2];
for(int i=2;i<n+2;i++)
  prime[i]=1;

int count=0;
for(int i=2;i*i<=n+1;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<=n+1;j+=i)
            {
                prime[j]=0;
            }
        }
    }

/*
for(int j=2;j<n+2;j++)
{
    cout<<j <<"=" <<prime[j]<<" ";

}cout<<endl; */

for(int i=2;i<n+2;i++)
{
    if(prime[i]==0)
        count++;
}
count++;
cout<<count<<endl;

int kprint=2;
  for(int j=2;j<=n+1;j++)
  {
      if(prime[j]==1)
      { cout<<"1 ";

      }
      else{
        cout<<kprint<<" ";
      }
  }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{

int n;
cin>>n;
int ar[n+1];
for(int i=1;i<=n;i++)
ar[i]=i+1;

int prime[n+2];
for(int i=2;i<n+2;i++)
  prime[i]=1;

int count=0;
for(int i=2;i*i<=n+1;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<=n+1;j+=i)
            {
                prime[j]=0;

            }
        }
    }

if(n>2)
{
    cout<<"2"<<endl;
}
else
{
    cout<<"1"<<endl;
}
for(int i=2;i<=n+1;i++)
{
    if(prime[i]==0)
    {
        cout<<"1 ";
    }
    else
    {
        cout<<"2 ";
    }
}

}


#include<bits/stdc++.h>
using namespace std;
int main()
{

int n;
cin>>n;
int ar[n+1];
for(int i=1;i<=n;i++)
ar[i]=i+1;

int prime[n+2];
for(int i=2;i<n+2;i++)
  prime[i]=1;

int count=0;
for(int i=2;i*i<=n+1;i++)
    {
        if(prime[i]==1)
        {
            for(int j=i*i;j<=n+1;j+=i)
            {
                prime[j]=0;

            }
        }
    }

if(n>2)
{
    cout<<"2"<<endl;
    for(int i=2;i<=n+1;i++)
{
    if(prime[i]==0)
    {
        cout<<"2 ";
    }
    else
    {
        cout<<"1 ";
    }
}
}
else
{
    cout<<"1"<<endl;
    for(int j=2;j<=n+1;j++)
    {
        cout<<"1 ";
    }
}

}


#include<bits/stdc++.h>
using namespace std;
int main()
{

int n;
cin>>n;
int ar[n+1];
for(int i=1;i<=n;i++)
ar[i]=i+1;

int prime[n+2];
for(int i=2;i<n+2;i++)
  prime[i]=1;

int count=0;
for(int i=2;i*i<=n+1;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<=n+1;j+=i)
            {
                prime[j]=0;
            }
        }
    }

/*
for(int j=2;j<n+2;j++)
{
    cout<<j <<"=" <<prime[j]<<" ";

}cout<<endl; */
/*
if(n==1)
{
    cout<<"1"<<endl<<"1";
    exit(0);
}
*/
for(int i=2;i<n+2;i++)
{
    if(prime[i]==0)
        count++;
}
count++;
cout<<count<<endl;

int kprint=2;
  for(int j=2;j<=n+1;j++)
  {
      if(prime[j]==1)
      { cout<<"1 ";

      }
      else{
        cout<<kprint<<" ";
        kprint++;
      }
  }

}


#include <iostream>
#include <math.h>
using namespace std;
bool is_prime(int);

int main()
{
    int a;
    cin>>a;
    if(a==2||a==1)
    {
        cout<<1<<'\n';
    }

    else
    {
        cout<<2<<'\n';
    }
    for(int i=1;i<=a;i++)
    {
        if(is_prime(i))
        {
            cout<<1<<' ';
        }
        else
        {
            cout<<2<<' ';
        }
    }
}
bool is_prime(int num)
{
	int i;
	if(num==1)
    {
		return 0;
	}
	else{
    for(i=2;i<=sqrt(num);i++)
    {
        if(num%i==0)
        {
				return 0;
        }
    }
	}
	return 1;
}


#include <iostream>
#include <math.h>
using namespace std;
bool is_prime(int);

int main()
{
    int a;
    cin>>a;
    if(a==2||a==1)
    {
        cout<<1<<'\n';
    }

    else
    {
        cout<<2<<'\n';
    }
    for(int i=1;i<=a;i++)
    {
        if(is_prime(i+1))
        {
            cout<<1<<' ';
        }
        else
        {
            cout<<2<<' ';
        }
    }
}
bool is_prime(int num)
{
	int i;
	if(num==1)
    {
		return 0;
	}
	else{
    for(i=2;i<=sqrt(num);i++)
    {
        if(num%i==0)
        {
				return 0;
        }
    }
	}
	return 1;
}


#include <iostream>
#include <math.h>
using namespace std;
bool is_prime(int);

int main()
{
    int a;
    cin>>a;
    if(a==2||a==1)
    {
        cout<<1<<'\n';
    }

    else
    {
        cout<<2<<'\n';
    }
    for(int i=1;i<=a;i++)
    {
        if(is_prime(i))
        {
            cout<<1<<' ';
        }
        else
        {
            cout<<2<<' ';
        }
    }
}
bool is_prime(int num)
{
	int i;
	if(num==1)
    {
		return 1;
	}
	else{
    for(i=2;i<sqrt(num);i++)
    {
        if(num%i==0)
        {
				return 0;
        }
    }
	}
	return 1;
}


#include <iostream>
#include <math.h>
using namespace std;
bool is_prime(int);

int main()
{
    int a;
    cin>>a;
    if(a==2||a==3)
    {
        cout<<1<<'\n';
    }

    else
    {
        cout<<2<<'\n';
    }
    for(int i=1;i<=a;i++)
    {
        if(is_prime(i))
        {
            cout<<1<<' ';
        }
        else
        {
            cout<<2<<' ';
        }
    }
}
bool is_prime(int num)
{
	int i;
	if(num==1)
    {
		return 1;
	}
	else{
    for(i=2;i<sqrt(num);i++)
    {
        if(num%i==0)
        {
				return 0;
        }
    }
	}
	return 1;
}