def main(): import sys sys.setrecursionlimit(1 << 25) C = sys.stdin.readline().strip() L = len(C) # Function to compute sum of bits for numbers 1..N def sum_bits(N): total = 0 m = 1 while (1 << (m-1)) <= N: start = 1 << (m-1) end = (1 << m) - 1 if end > N: end = N count = end - start + 1 total += count * m m += 1 return total # Binary search to find N low = 1 high = 2 * 10**6 # Arbitrary large value found = None while low <= high: mid = (low + high) // 2 s = sum_bits(mid) if s == L: found = mid break elif s < L: low = mid + 1 else: high = mid - 1 if not found: print("No solution found") return N = found print("N =", N, file=sys.stderr) # Precompute binary strings and their integer values binary_dict = {} for i in range(1, N+1): binary = bin(i)[2:] binary_dict[binary] = i # Precompute all possible binary strings and their end positions binary_strings = list(binary_dict.keys()) max_len = max(len(s) for s in binary_strings) # Backtracking with memoization permutation = [] used = [False] * (N + 1) result = None def backtrack(pos): nonlocal result if result is not None: return if pos == len(C): if len(permutation) == N: result = permutation.copy() return if pos > len(C): return # Try all possible binary strings starting at pos for m in range(1, max_len + 1): if pos + m > len(C): continue substring = C[pos:pos+m] if substring in binary_dict: num = binary_dict[substring] if not used[num]: used[num] = True permutation.append(num) backtrack(pos + m) if result is not None: return permutation.pop() used[num] = False backtrack(0) if result is None: print("No solution found") else: print(' '.join(map(str, result))) if __name__ == "__main__": main()