from sys import setrecursionlimit setrecursionlimit(10**6) def operator1(C): M = len(C) cnt = 0 for b in range(1,1<<16): cnt += len(bin(b)) - 2 if cnt == M: return b, M, len(bin(b)) - 2 def operator2(C, N, M, B): Num = [[] for _ in range(N+1)] for i in range(M): for b in range(1,B+1): if i + b - 1 >= M: break if i + b < M and C[i+b] == '0': continue c = int(C[i:i+b], 2) if c == 0 or c > N: break Num[c].append(i) return Num def operator3(N, B): Cnt = [[] for _ in range(B)] for i in range(N,0,-1): B = bin(i)[2:] Len = 0 cnt = 0 for b in B: if b == '0': cnt += 1 else: cnt = 0 Len = max(Len, cnt) Cnt[Len].append(i) return Cnt def dfs(x, y): global Flg, ans, Num, Cnt if x == len(Cnt[y]): x = 0 y -= 1 if y == -1: Answer() C = Cnt[y][x] B = len(bin(C)) - 2 for i in Num[C]: Flg2 = 1 for b in range(B): if Flg[i+b]: Flg2 = 0 break if Flg2: ans[C] = i for b in range(B): Flg[i+b] = 1 dfs(x+1, y) for b in range(B): Flg[i+b] = 0 def Answer(): global ans for i in range(N+1): ans[i] = [ans[i], i] ans = ans[1:] ans.sort() for i in range(N): ans[i] = ans[i][1] print(*ans) exit() C = input() N,M,B = operator1(C) Num = operator2(C, N, M, B) Cnt = operator3(N, B) Flg = [0] * M ans = [0] * (N+1) dfs(0, B-1)