#!/usr/bin/env python3
import sys, random, math, time
N=int(sys.argv[1]); seed=int(sys.argv[2]) if len(sys.argv)>2 else 1
random.seed(seed)
spf=list(range(N+1))
pr=[]
for i in range(2,N+1):
    if spf[i]==i:
        pr.append(i)
    for p in pr:
        if p* i>N or p>spf[i]: break
        spf[p*i]=p
sign=[0]*(N+1); f=[0]*(N+1); f[1]=1; sign[1]=1
S=1
for n in range(2,N+1):
    if spf[n]==n:
        # prime choose sign to keep S near 0
        if S>=3: val=-1
        elif S<=-3: val=1
        else: val=-1 if S>0 else (1 if S<0 else (1 if random.getrandbits(1) else -1))
        sign[n]=val; f[n]=val
    else:
        p=spf[n]; m=n//p
        f[n]=sign[p]*f[m]
    S += f[n]
    if abs(S)>3:
        print('fail at',n,'S',S,'spf',spf[n],'f',f[n]); sys.exit(1)
print('ok',N,'primes',len(pr),'S',S)
print(''.join('1' if f[i]>0 else '0' for i in range(1,min(N,200)+1)))
