import sys sys.setrecursionlimit(1 << 25) def main(): C = sys.stdin.read().strip() L = len(C) # Step 1: Compute N sum_bits = 0 N = 0 while True: N += 1 bits = N.bit_length() sum_bits += bits if sum_bits == L: break elif sum_bits > L: print("No solution found", file=sys.stderr) return # Step 2: Precompute all binary strings for 1..N binary_strings = [bin(x)[2:] for x in range(1, N+1)] binary_dict = {s: x for x, s in enumerate(binary_strings, 1)} max_len = max(len(s) for s in binary_strings) # Step 3: Backtracking approach result = [] used = set() def backtrack(pos, used_set, permutation): nonlocal result if pos == len(C): if len(used_set) == N: result = permutation.copy() return if result: return # Try all possible lengths from max_len down to 1 for l in range(max_len, 0, -1): if pos + l > len(C): continue substr = C[pos:pos+l] if substr in binary_dict: x = binary_dict[substr] if x not in used_set: new_used = used_set.copy() new_used.add(x) backtrack(pos + l, new_used, permutation + [x]) if result: return backtrack(0, set(), []) print(' '.join(map(str, result))) if __name__ == "__main__": main()