#!/usr/bin/env python3
import sys, random, time
N=int(sys.argv[1]); seed=int(sys.argv[2]) if len(sys.argv)>2 else 1
random.seed(seed)
# divisors lists d for i where i/d>=1 and d<=N//4 only; need all for sums if length may reach 4 later
Ds=[[] for _ in range(N+1)]
for d in range(1,N//4+1):
    for j in range(d,N+1,d): Ds[j].append(d)
seq=[0]*(N+1); sums=[0]*(N//4+1)
choices=[]
for i in range(1,N+1):
    forced=0; bad=False; scorep=scoren=0
    for d in Ds[i]:
        k=i//d; s=sums[d]
        if k>=4 and k%2==0:
            if s>=3:
                if forced==1: bad=True; break
                forced=-1
            if s<=-3:
                if forced==-1: bad=True; break
                forced=1
        # score after val toward 0 for all progressions
        scorep += abs(s+1)
        scoren += abs(s-1)
    if bad:
        print('fail conflict at',i,'seed',seed); sys.exit(1)
    if forced:
        val=forced
    else:
        # choose sign minimizing total abs with random noise
        if scorep<scoren: val=1
        elif scoren<scorep: val=-1
        else: val=1 if random.getrandbits(1) else -1
    seq[i]=val
    for d in Ds[i]: sums[d]+=val
    if i%10000==0: print('at',i,'maxsum',max(abs(x) for x in sums), flush=True)
print('ok',N,'maxsum',max(abs(x) for x in sums))
print(''.join('1' if seq[i]>0 else '0' for i in range(1,N+1))[:200])
