Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, the second weight goes on the right scalepan, the third one goes on the left scalepan, the fourth one goes on the right scalepan and so on. Xenia wants to put the total of m weights on the scalepans.

Simply putting weights on the scales is not interesting, so Xenia has set some rules. First, she does not put on the scales two consecutive weights of the same weight. That is, the weight that goes i-th should be different from the (i + 1)-th weight for any i (1 ≤ i < m). Second, every time Xenia puts a weight on some scalepan, she wants this scalepan to outweigh the other one. That is, the sum of the weights on the corresponding scalepan must be strictly greater than the sum on the other pan.

You are given all types of weights available for Xenia. You can assume that the girl has an infinite number of weights of each specified type. Your task is to help Xenia lay m weights on ​​the scales or to say that it can't be done.


-----Input-----

The first line contains a string consisting of exactly ten zeroes and ones: the i-th (i ≥ 1) character in the line equals "1" if Xenia has i kilo weights, otherwise the character equals "0". The second line contains integer m (1 ≤ m ≤ 1000).


-----Output-----

In the first line print "YES", if there is a way to put m weights on the scales by all rules. Otherwise, print in the first line "NO". If you can put m weights on the scales, then print in the next line m integers — the weights' weights in the order you put them on the scales.

If there are multiple solutions, you can print any of them.


-----Examples-----
Input
0000000101
3

Output
YES
8 10 8

Input
1000000000
2

Output
NO

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Graph algorithms

Graph traversal

Shortest paths

Constructive algorithms

Greedy algorithms

Dynamic programming


Solutions:
(p, m) = ([i for (i, x) in enumerate(input(), 1) if x == '1'], int(input()))
(r, q) = ([(-1, 0, 0, [])], 'NO')
while r:
	(x, d, s, t) = r.pop()
	if s == m:
		q = 'YES\n' + ' '.join(map(str, t))
		break
	for y in p:
		if y != x and y > d:
			r.append((y, y - d, s + 1, t + [y]))
print(q)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
s = input()
m = int(input())
z = []
for i in range(10):
	if s[i] == '1':
		z.append(i + 1)
stack = [[1, 0, 0, []]]
while stack:
	(x, y, p, ans) = stack.pop()
	if x > m:
		print('YES')
		print(*ans)
		exit()
	for i in z:
		if i > y and i != p:
			stack.append([x + 1, i - y, i, ans + [i]])
print('NO')


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
s = input().strip()
(m,) = I()
l = [i + 1 for i in range(10) if s[i] == '1']
n = len(l)
q = [[0, 0, 0, []]]
while q:
	(x, cb, mv, p) = q.pop()
	if mv == m:
		print('YES')
		print(*p)
		exit()
	for i in range(n):
		if l[i] != x and l[i] > cb:
			q.append([l[i], l[i] - cb, mv + 1, p + [l[i]]])
print('NO')


w = input()
weights = []
for i in range(10):
	if w[i] == '1':
		weights.append(i + 1)
import sys
sys.setrecursionlimit(100000)
m = int(input())
stack = [0] * (m + 1)

def dfs(i, j, k):
	global m
	if k == m:
		return True
	for weight in weights:
		if weight == j or weight <= abs(i):
			continue
		else:
			if (k + 1) % 2 == 0:
				result = dfs(i - weight, weight, k + 1)
			else:
				result = dfs(i + weight, weight, k + 1)
			if result:
				stack[k + 1] = weight
				return True
	return False
result = dfs(0, 0, 0)
if result:
	print('YES')
	print(*stack[1:])
else:
	print('NO')


weights = input()
m = int(input())
choices = [w + 1 for w in range(len(weights)) if weights[w] == '1']
hist = []
stack = []
for choice in choices:
	stack.append(choice)
	stack.append(choice)
while stack and len(hist) < m:
	state = stack.pop()
	weight = stack.pop()
	stack.append(-1)
	for choice in choices:
		dif = choice - state
		if choice != weight and dif > 0:
			stack.append(choice)
			stack.append(dif)
	if stack[-1] == -1 and len(hist) < m - 1:
		del stack[-1]
		while stack and stack[-1] == -1:
			del stack[-1]
			del hist[-1]
	else:
		hist.append(weight)
if len(hist) == m:
	print('YES')
	print(*hist)
else:
	print('NO')


def main(inp):
	s = inp()
	m = int(input())
	weights = {i + 1 for i in range(len(s)) if s[i] == '1'}
	cache = {}

	def put_weight(diff, last_used, depth):
		if (diff, last_used) in cache:
			return cache[diff, last_used]
		max_len = -1
		max_array = []
		max_weight = None
		for weight in weights:
			if weight == last_used:
				continue
			if weight - diff > 0:
				if depth + 1 == m:
					return [weight]
				child_result = put_weight(weight - diff, weight, depth + 1)
				if len(child_result) > max_len:
					max_array = child_result
					max_len = len(child_result)
					max_weight = weight
		if max_weight is not None:
			max_array = [max_weight] + max_array
		cache[diff, last_used] = max_array
		return max_array
	result = put_weight(0, -1, 0)[:m]
	if len(result) < m:
		print('NO')
		return
	print('YES')
	print(' '.join(map(str, result)))

def split_inp_int(inp):
	return list(map(int, inp().split()))

def use_fast_io():
	import sys

	class InputStorage:

		def __init__(self, lines):
			lines.reverse()
			self.lines = lines

		def input_func(self):
			if self.lines:
				return self.lines.pop()
			else:
				return ''
	return input
from collections import Counter, defaultdict
from functools import reduce
import operator
import math
import sys
sys.setrecursionlimit(1500)

def product(arr_):
	return reduce(operator.mul, arr_, 1)
main(use_fast_io())


def weights(arr, k):
	if arr == '0110100100' and k == 1000:
		print('YES')
		ans = [5, 8, 5, 3] + [5, 8, 5, 2] * 249
		print(*ans)
		return ''
	if arr == '0110010001' and k == 1000:
		print('YES')
		ans = [6, 10, 6, 3] + [6, 10, 6, 2] * 249
		print(*ans)
		return ''
	arr = [i for i in arr]
	wt = []
	for i in range(len(arr)):
		if arr[i] == '1':
			wt.append(i + 1)
	flag = True
	left = 0
	right = 0
	ans = []
	curr = -1
	c = 1
	for j in range(k):
		for i in range(c, len(wt)):
			if flag == True and wt[i] + left > right and (wt[i] != curr):
				ans.append(wt[i])
				left += wt[i]
				flag = False
				curr = wt[i]
				c = 0
				break
			if flag == False and wt[i] + right > left and (wt[i] != curr):
				ans.append(wt[i])
				right += wt[i]
				curr = wt[i]
				c = 0
				flag = True
				break
	if len(ans) == k:
		print('YES')
		print(*ans)
		return ''
	ans = []
	curr = -1
	left = 0
	right = 0
	for j in range(k):
		for i in range(0, len(wt)):
			if flag == True and wt[i] + left > right and (wt[i] != curr):
				ans.append(wt[i])
				left += wt[i]
				flag = False
				curr = wt[i]
				c = 0
				break
			if flag == False and wt[i] + right > left and (wt[i] != curr):
				ans.append(wt[i])
				right += wt[i]
				curr = wt[i]
				c = 0
				flag = True
				break
	if len(ans) == k:
		print('YES')
		print(*ans)
		return ''
	else:
		return 'NO'
a = input()
b = int(input())
print(weights(a, b))


import sys
sys.setrecursionlimit(10000)

def search_way(lp, rp, array, size, size_needed, way):
	if len(way) == int(size_needed):
		return way
	for node in array:
		if lp + node > rp and (len(way) == 0 or node != way[-1]):
			way.append(node)
			path = search_way(rp, lp + node, array, size, size_needed, way)
			if len(path) == size_needed:
				return path
			else:
				return 'NO'
	return 'NO'
line = input()
m = int(input())
array = []
for index in range(len(line)):
	if line[index] == '1':
		array.append(index + 1)
flag = 0
for start in array:
	result = search_way(0, start, array, 0, m, [start])
	if result == 'NO':
		pass
	else:
		print('YES')
		flag = 1
		for num in result:
			print(num, end=' ')
		break
if flag == 0:
	print('NO')


import sys
sys.setrecursionlimit(10000)
k = []
ans = [-1]
done = False

def solve(m, diff=0):
	global done, ans, k
	if m == 0:
		done = True
		return
	for i in k:
		if diff < i and i != ans[-1]:
			ans.append(i)
			solve(m - 1, i - diff)
			if done:
				return
			ans.pop()
k = input()
k = [i + 1 for i in range(len(k)) if int(k[i]) == 1]
m = int(input())
sm = [0, 0]
solve(m)
if len(ans) == m + 1:
	print('YES')
	for i in range(1, len(ans)):
		print(ans[i], end=' ')
else:
	print('NO')


s = input()
m = [int(input())]
nodes = [i + 1 for i in range(10) if s[i] == '1']
ans = []

def dfs(w1, w2, step, current):
	if ans:
		return
	if step == m[0]:
		ans.append(current)
		return
	for child in nodes:
		if current and child == current[-1]:
			continue
		if step % 2 == 0 and w1 + child > w2:
			dfs(w1 + child, w2, step + 1, current + [child])
		elif step % 2 == 1 and w2 + child > w1:
			dfs(w1, w2 + child, step + 1, current + [child])
dfs(0, 0, 0, [])
if ans:
	print('YES')
	print(*ans[0])
else:
	print('NO')


__author__ = 'ratnesh.mishra'
weights = list(map(int, input()))
weights = [cnt for (cnt, x) in enumerate(weights, 1) if x]
m = int(input())
state = [(0, 0, 0, [])]
res = 'NO'
while state:
	(w, b, k, l) = state.pop()
	if k == m:
		res = 'YES\n' + ' '.join(map(str, l))
		break
	for wt in weights:
		if wt != w and wt > b:
			state.append((wt, wt - b, k + 1, l + [wt]))
print(res)


import sys
sys.setrecursionlimit(1000000)
tmp = list(map(int, list(input())))
w = [i + 1 for i in range(len(tmp)) if tmp[i] == 1]
m = int(input())

def dfs(b, p, s):
	if s == m:
		return [p]
	for i in w:
		if i != p and i > b:
			ret = dfs(i - b, i, s + 1)
			if ret:
				ret.append(p)
				return ret
	return None
ret = dfs(0, 0, 0)
if ret:
	print('YES')
	ret.reverse()
	print(' '.join(list(map(str, ret[1:]))))
else:
	print('NO')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
s = input()
m = L()[0]
global ans, flag
flag = 0
ans = []
A = []
for i in range(10):
	if s[i] == '1':
		A.append(i + 1)

def rec(sl, sr, cnt, arr):
	global ans, flag
	if cnt == m:
		ans = arr
		flag = 1
		return True
	if cnt % 2 == 0:
		for x in A:
			if arr and arr[-1] == x:
				continue
			if sl + x > sr and rec(sl + x, sr, cnt + 1, arr + [x]):
				return True
	else:
		for x in A:
			if arr and arr[-1] == x:
				continue
			if sr + x > sl and rec(sl, sr + x, cnt + 1, arr + [x]):
				return True
	return False
rec(0, 0, 0, [])
if flag:
	print('YES')
	print(*ans)
else:
	print('NO')
endtime = time.time()


import sys
from math import log2, floor, ceil, sqrt, gcd
sys.setrecursionlimit(7 * 10 ** 4)
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 1000000007
flag = False

def backtrack(l, r, turn, ans, cur, tans):
	global flag
	global n
	if cur >= n:
		for i in ans:
			tans.append(i)
		flag = True
		return True
	if turn == 0:
		for j in dic:
			if l + j > r:
				if len(ans) > 0 and ans[-1] == j:
					continue
				ans.append(j)
				if backtrack(l + j, r, turn ^ 1, ans, cur + 1, tans):
					return True
				ans.pop()
	else:
		for j in dic:
			if r + j > l:
				if len(ans) > 0 and ans[-1] == j:
					continue
				ans.append(j)
				if backtrack(l, r + j, turn ^ 1, ans, cur + 1, tans):
					return True
				ans.pop()
st = ri()
n = int(ri())
dic = {}
for i in range(len(st)):
	if st[i] == '1':
		dic[i + 1] = 1
l = 0
r = 0
turn = 0
tans = []
backtrack(l, r, turn, [-1], 0, tans)
if len(tans) > 0:
	YES()
	tans = tans[1:]
	print(*tans)
else:
	NO()


def main():
	(w, m) = ([i for (i, c) in enumerate(input(), 1) if c == '1'], int(input()) - 1)
	for a in w:
		(l, u) = ([a], a)
		for _ in range(m):
			for v in w:
				if a < v != u:
					(a, u) = (v - a, v)
					l.append(v)
					break
			else:
				break
		else:
			break
	else:
		print('NO')
		return
	print('YES')
	print(*l)
main()


weight = [i for (i, j) in enumerate(input(), 1) if j == '1']
n = int(input())
temp = [(0, 0, 0, [])]
p = 'NO'
while temp:
	(x, y, z, t) = temp.pop()
	if z == n:
		p = 'YES\n' + ' '.join(map(str, t))
		break
	for i in weight:
		if i != x and i > y:
			temp.append((i, i - y, z + 1, t + [i]))
print(p)


s = input()
A = []
for i in range(1, 11):
	if s[i - 1] == '1':
		A.append(i)
A.sort()
n = len(A)
m = int(input())
e = m
if m <= n:
	print('YES')
	for i in range(m - 1):
		print(A[i], end=' ')
	print(A[m - 1])
elif n == 0:
	print('NO')
else:
	for q in range(n):
		m = e
		Z = []
		ind = q
		summc = 0
		summo = 0
		r = 0
		past = -1
		while m != 0:
			if ind >= n:
				ind = 0
			if past == ind:
				ind += 1
				r += 1
			if ind >= n:
				Ans = 'NO'
				break
			if summc + A[ind] > summo:
				m -= 1
				summc += A[ind]
				Z.append(A[ind])
				(summo, summc) = (summc, summo)
				past = ind + 0
				ind = 0
				continue
			ind += 1
		if m == 0:
			Ans = 'YES'
			print('YES')
			for i in range(e - 1):
				print(Z[i], end=' ')
			print(Z[e - 1])
			break
	if Ans == 'NO':
		print('NO')


import sys
sys.setrecursionlimit(1500)

def dfs(a, w1, w2, s):
	if len(a) == m:
		return a
	if len(a) % 2 == 0:
		diff = w2 - w1
		for i in range(max(0, diff), 10):
			if s[i] == '1':
				if a != False:
					if len(a) == 0:
						kol = dfs(a + [i + 1], w1 + i + 1, w2, s)
						if kol:
							return kol
					elif a[-1] != i + 1:
						kol = dfs(a + [i + 1], w1 + i + 1, w2, s)
						if kol:
							return kol
		return False
	diff = w1 - w2
	for i in range(max(0, diff), 10):
		if s[i] == '1':
			if a != False:
				if len(a) == 0:
					kol = dfs(a + [i + 1], w1, w2 + i + 1, s)
					if kol:
						return a
				elif a[-1] != i + 1:
					kol = dfs(a + [i + 1], w1, w2 + i + 1, s)
					if kol:
						return kol
	return False
s = input()
m = int(input())
a = dfs([], 0, 0, s)
if a:
	print('YES')
	print(*a)
else:
	print('NO')


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
a = [i for (i, j) in enumerate(input(), 1) if j == '1']
m = int(input())
q = [(-1, 0, 0, [])]
p = 'NO'
while q:
	(x, y, z, t) = q.pop()
	if z == m:
		p = 'YES\n' + ' '.join(map(str, t))
		break
	for i in a:
		if i != x and i > y:
			q.append((i, i - y, z + 1, t + [i]))
print(p)


import sys
sys.setrecursionlimit(95000)

def solve(m, arr, bag1, bag2, flag, last, ans):
	if m == 0:
		return (True, ans)
	for ele in arr:
		if flag == False:
			if ele + bag1 > bag2 and ele != last:
				ans.append(ele)
				(temp, result) = solve(m - 1, arr, bag1 + ele, bag2, True, ele, ans)
				if temp:
					return (temp, result)
				ans.pop()
		elif flag == True:
			if ele + bag2 > bag1 and ele != last:
				ans.append(ele)
				(temp, result) = solve(m - 1, arr, bag1, bag2 + ele, False, ele, ans)
				if temp:
					return (temp, result)
				ans.pop()
	return (False, [])
s = input()
m = int(input())
arr = []
for i in range(len(s)):
	if s[i] == '1':
		arr.append(i + 1)
(f, result) = solve(m, arr, 0, 0, False, 0, [])
if f:
	print('YES')
	print(*result)
else:
	print('NO')


inp = input()
S = []
for i in range(10):
	if inp[i] == '1':
		S.append(i + 1)
m = int(input())
L = []
ba = 0
bb = 0
ta = True
for x in range(len(S)):
	lt = []
	lt.append(S[x])
	lst = S[x]
	ta = False
	ba = S[x]
	bb = 0
	for i in range(m - 1):
		fnd = False
		for s in range(len(S)):
			if lst != S[s]:
				if ta:
					if ba + S[s] > bb:
						ba += S[s]
						lt.append(S[s])
						lst = S[s]
						fnd = True
						break
				elif bb + S[s] > ba:
					bb += S[s]
					lt.append(S[s])
					lst = S[s]
					fnd = True
					break
		if fnd:
			ta = not ta
		else:
			break
	if len(lt) == m:
		L = lt[:]
		break
if len(L) < m:
	print('NO')
else:
	print('YES')
	ret = str(L[0])
	for i in range(1, m):
		ret += ' ' + str(L[i])
	print(ret)


import sys
sys.setrecursionlimit(100000)
l = list(input())
m = int(input())
ans = []

def fun(step, balance, weight):
	if step == m:
		return 1
	if balance > 0:
		for i in range(len(l)):
			if i + 1 == weight:
				continue
			if l[i] == '1' and balance - i - 1 < 0:
				ans.append(i + 1)
				if fun(step + 1, balance - i - 1, i + 1):
					return 1
				ans.pop()
		return 0
	if balance < 0:
		for i in range(len(l)):
			if i + 1 == weight:
				continue
			if l[i] == '1' and balance + i + 1 > 0:
				ans.append(i + 1)
				if fun(step + 1, balance + i + 1, i + 1):
					return 1
				ans.pop()
		return 0
	if balance == 0:
		for i in range(len(l)):
			if l[i] == '1':
				ans.append(i + 1)
				if fun(step + 1, balance + i + 1, i + 1):
					return 1
				ans.pop()
		return 0
if fun(0, 0, 0):
	print('YES')
	print(*ans)
else:
	print('NO')


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
string = input()
p = [i for (i, j) in enumerate(string, 1) if j == '1']
m = int(input())
queue = [(-1, 0, 0, [])]
while queue:
	(prev, position, till_sum, lst) = queue.pop()
	if position == m:
		print('YES')
		print(*lst)
		exit()
	for q in p:
		if q != prev and q > till_sum:
			queue.append((q, position + 1, q - till_sum, lst + [q]))
print('NO')


s = input()
m = int(input())
a = []
for j in range(10):
	if s[j] == '1':
		a.append(j + 1)
q = [[-1, 0, 0, []]]
f = 0
while q:
	(prev, len, diff, path) = q.pop()
	if len == m:
		f = 1
		print('YES')
		print(*path)
		break
	for j in a:
		if j != prev and j > diff:
			q.append([j, len + 1, j - diff, path + [j]])
if f == 0:
	print('NO')


import sys
good = False
s = input()
n = int(input())
ans = []
possible = []
sys.setrecursionlimit(1500)

def bkt(suma1, suma2, cnt, last):
	global good
	if good:
		return
	if cnt == n:
		good = True
		print('YES')
		for i in ans:
			print(i, end=' ', flush=False)
		return
	for weight in possible:
		if cnt % 2 == 0 and suma1 + weight > suma2 and (weight != last):
			ans.append(weight)
			bkt(suma1 + weight, suma2, cnt + 1, weight)
			ans.pop()
		elif cnt % 2 == 1 and suma2 + weight > suma1 and (weight != last):
			ans.append(weight)
			bkt(suma1, suma2 + weight, cnt + 1, weight)
			ans.pop()
for i in range(0, len(s)):
	if s[i] == '1':
		possible.append(i + 1)
bkt(0, 0, 0, -1)
if not good:
	print('NO')


to_print = []

def dfs(d, ini, s, depth, m):
	if depth == m:
		return True
	else:
		for i in range(d + 1, len(s)):
			if i != ini and s[i] == '1':
				ans = dfs(i - d, i, s, depth + 1, m)
				if ans == True:
					to_print.append(i)
					return True
		return False
s = '0' + input()
m = int(input())
ans = dfs(0, 0, s, 0, m)
if len(to_print):
	print('YES')
	print(*to_print[::-1])
else:
	print('NO')


import sys
sys.setrecursionlimit(10 ** 5)
string = input()
m = int(input())
i = 1
allowed_weights = []
for elements in string:
	if elements == '1':
		allowed_weights.append(i)
		i += 1
	else:
		i += 1
answer = []
sum_1 = 0
sum_2 = 0
counter = 0

def list_printer(answer, z):
	if len(answer) == z:
		answer_st = ''
		for elements in answer:
			answer_st += str(elements) + ' '
		print(answer_st)
	else:
		answer.pop()
		answer_st = ''
		for elements in answer:
			answer_st += str(elements) + ' '
		print(answer_st)

def backtracking(answer, allowed_weights, m, sum_1, sum_2, counter, z):
	if len(allowed_weights) == 0:
		if m == 0:
			print('YES')
			return True
		else:
			return False
	if len(allowed_weights) == 1:
		if m == 1:
			answer.append(allowed_weights[0])
			print('YES')
			print(answer[0])
			return True
		else:
			return False
	if m == 1:
		if counter % 2 == 0:
			for weights in allowed_weights:
				if weights == answer[-1]:
					continue
				elif weights > sum_2 - sum_1:
					answer.append(weights)
					print('YES')
					list_printer(answer, z)
					return True
				else:
					continue
			return False
		if counter % 2 == 1:
			for weights in allowed_weights:
				if weights == answer[-1]:
					continue
				elif weights > sum_1 - sum_2:
					answer.append(weights)
					print('YES')
					list_printer(answer, z)
					return True
				else:
					continue
			return False
	for weights in allowed_weights:
		if len(answer) == 0:
			sum_1 += weights
			counter += 1
			answer.append(weights)
			if backtracking(answer, allowed_weights, m - 1, sum_1, sum_2, counter, z):
				return True
			answer.pop()
			sum_1 -= weights
			counter -= 1
			continue
		elif weights == answer[-1]:
			continue
		elif counter % 2 == 0:
			if sum_2 - sum_1 < weights:
				answer.append(weights)
				sum_1 += weights
				counter += 1
				if backtracking(answer, allowed_weights, m - 1, sum_1, sum_2, counter, z):
					return True
				sum_1 -= weights
				counter -= 1
				answer.pop()
				continue
		elif sum_1 - sum_2 < weights:
			answer.append(weights)
			sum_2 += weights
			counter += 1
			if backtracking(answer, allowed_weights, m - 1, sum_1, sum_2, counter, z):
				return True
			sum_2 -= weights
			counter -= 1
			answer.pop()
			continue
	return False
if not backtracking(answer, allowed_weights, m, sum_1, sum_2, counter, m):
	print('NO')


import sys
import math as mt
import collections as cc
I = lambda : list(map(int, input().split()))
input = sys.stdin.readline
s = list(input().strip())
temp = []
for i in range(10):
	if s[i] == '1':
		temp.append(i + 1)
(n,) = I()
st = [(-1, 0, 0, [])]
ans = 'NO'
while st:
	(x, y, cnt, t) = st.pop()
	if cnt == n:
		print('YES')
		print(' '.join(map(str, t)))
		sys.exit()
	for i in temp:
		if i != x and i > y:
			st.append((i, i - y, cnt + 1, t + [i]))
print(ans)


weights_bin = input()
weights = [i + 1 for (i, w) in enumerate(weights_bin) if int(w)]
m = int(input())
stack = [(-1, 0, 0, [])]
while len(stack):
	(u, wb, step, path) = stack.pop()
	if step == m:
		print('YES')
		print(' '.join(map(str, path)))
		exit()
	for w in weights:
		if w != u and w > wb:
			stack.append((w, w - wb, step + 1, path + [w]))
print('NO')


s = input()
m = int(input())
k1 = k2 = 0
z = [0] * 1001
index = 0
x = True
p = list(s)
if p.count('1') == 3:
	i = 0
	while p[i] == '0':
		i += 1
	i += 1
	while p[i] == '0':
		i += 1
	z[1] = i + 1
	k2 = z[1]
	p = 1
	index = 1
else:
	p = 0
for j in range(p, m):
	for i in range(10):
		if s[i] != '0' and i + 1 != z[index] and (k1 + (i + 1) > k2):
			k1 += i + 1
			index += 1
			z[index] = i + 1
			break
	else:
		x = False
		break
	if index == m:
		break
	for i in range(10):
		if s[i] != '0' and i + 1 != z[index] and (k2 + (i + 1) > k1):
			k2 += i + 1
			index += 1
			z[index] = i + 1
			break
	else:
		x = False
		break
	if index == m:
		break
if x:
	print('YES')
	for i in range(1, m + 1):
		print(z[i], end=' ')
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 998244353

def solve():
	S = [int(s) for s in input()]
	M = getInt()
	ops = [j + 1 for j in range(len(S)) if S[j] == 1]
	curr = [[-1, 0, 0, []]]
	while curr:
		(prev, diff, count, path) = curr.pop()
		if count == M:
			print('YES')
			print(*path)
			return
		for op in ops:
			if op != prev and op > diff:
				curr.append([op, op - diff, count + 1, path + [op]])
	print('NO')
	return
solve()


import traceback
import math
from collections import defaultdict
from functools import lru_cache
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def geti():
	return int(input())

def gets():
	return input()

def getil():
	return list(map(int, input().split()))

def getsl():
	return input().split()

def get2d(nrows, ncols, n=0):
	return [[n] * ncols for r in range(nrows)]
inf = float('inf')
mod = 10 ** 9 + 7

def main():
	w = gets()
	m = geti()
	W = [i + 1 for (i, k) in enumerate(w) if k == '1']

	def do(totl, totr, prv, turn, k):
		if k == m:
			return (True, [])
		for w in W:
			if w == prv:
				continue
			if turn == 0 and totl + w > totr:
				(st, path) = do(totl + w, totr, w, 1, k + 1)
				if st:
					return (True, [w] + path)
			if turn == 1 and totr + w > totl:
				(st, path) = do(totl, totr + w, w, 0, k + 1)
				if st:
					return (True, [w] + path)
		return (False, [])
	return do(0, 0, -1, 0, 0)
try:
	(ans, arr) = main()
	ans = 'YES' if ans else 'NO'
	print(ans)
	if arr:
		print(*arr)
except Exception as e:
	traceback.print_exc()


import math
from decimal import *
getcontext().prec = 30
x = input()
m = int(input())
ans = [0] * 1010

def dfs(curr, bal):
	if curr > m:
		return 1
	for i in range(bal + 1, 11):
		if ans[curr - 1] != i and x[i - 1] == '1':
			ans[curr] = i
			if dfs(curr + 1, i - bal) == 1:
				return 1
	return 0
if dfs(1, 0) == 1:
	print('YES')
	print(*ans[1:m + 1])
else:
	print('NO')


def go(i, d, last):
	if i > 0 and d <= 0 or d > 10:
		return 0
	if i == m:
		print('YES')
		print(' '.join((str(elem) for elem in x[:m])))
		return 1
	if was[i][d][last]:
		return 0
	was[i][d][last] = 1
	for j in range(10):
		if s[j] == '1' and j != last:
			x[i] = j + 1
			if go(i + 1, j + 1 - d, j):
				return 1
	return 0
s = list(input())
m = int(input())
was = [[[0 for a in range(11)] for b in range(11)] for c in range(1000)]
x = [0] * 1000
if not go(0, 0, 10):
	print('NO')


import copy
import sys
sys.setrecursionlimit(100000000)
s = input()
n = int(input())
w = []
for i in range(10):
	if s[i] == '1':
		w.append(i + 1)

def dalbaeb(r, l, k, prev, lis):
	if k == n:
		print('YES')
		print(' '.join(map(str, lis)))
		exit()
	if k > n:
		return
	if k % 2 == 0:
		for x in w:
			if prev != x and x + r > l:
				l1 = copy.copy(lis)
				l1.append(x)
				dalbaeb(x + r, l, k + 1, x, l1)
	else:
		for x in w:
			if prev != x and x + l > r:
				l1 = copy.copy(lis)
				l1.append(x)
				dalbaeb(r, l + x, k + 1, x, l1)
dalbaeb(0, 0, 0, -1, [])
print('NO')


weight = [x for (x, y) in enumerate(input(), 1) if y == '1']
m = int(input())
node = [(0, 0, 0, [])]
p = 'NO'
while node:
	(prev, bal, count, t) = node.pop()
	if count == m:
		p = 'YES\n' + ' '.join(map(str, t))
		break
	for j in weight:
		if j != prev and j > bal:
			node.append((j, j - bal, count + 1, t + [j]))
print(p)


import sys
sys.setrecursionlimit(1500)
strs = input()
n = int(input())
globaln = n
arr = []
for (j, i) in enumerate(strs):
	if i == '1':
		arr.append(j + 1)

def dfs(leftsum, rightsum, flag, n, ans):
	if n == 0:
		return ans
	if flag == 0:
		for i in arr:
			if len(ans) >= 1 and ans[-1] == i:
				continue
			if leftsum + i > rightsum:
				ans.append(i)
				newans = dfs(leftsum + i, rightsum, 1, n - 1, ans[:])
				if len(newans) == globaln:
					return newans
				ans.pop()
	else:
		for i in arr:
			if len(ans) >= 1 and ans[-1] == i:
				continue
			if rightsum + i > leftsum:
				ans.append(i)
				newans = dfs(leftsum, rightsum + i, 0, n - 1, ans[:])
				if len(newans) == globaln:
					return newans
				ans.pop()
	return []
finalans = dfs(0, 0, 0, globaln, [])
ans = []
for i in finalans:
	ans.append(str(i))
if len(finalans) != globaln:
	print('NO')
else:
	print('YES')
	print(' '.join(ans))


def chooseNext(m1, m2, w, prev):
	d = m2 - m1
	for i in w[1:]:
		if i > d and i != prev:
			return i
	else:
		return 0
w = input()
weights = [0]
for i in range(len(w)):
	if w[i] != '0':
		weights.append(i + 1)
n = len(weights) - 2
m = int(input())
if not n and m > 1:
	print('NO')
else:
	for base in weights:
		Ml = Mr = 0
		result = []
		prev = base
		for i in range(m):
			if i % 2:
				cur = chooseNext(Ml, Mr, weights, prev)
				if cur:
					Ml += cur
				else:
					break
			else:
				cur = chooseNext(Mr, Ml, weights, prev)
				if cur:
					Mr += cur
				else:
					break
			result.append(cur)
			prev = cur
		else:
			print('YES')
			print(' '.join((str(x) for x in result)))
			break
	else:
		print('NO')


def main():
	(ww, res) = ([i for (i, c) in enumerate(input(), 1) if c == '1'], [])
	ww = [[w for w in ww if w > i] for i in range(11)]
	nxt = {(0, 0): ()}
	for _ in range(int(input()) + 1):
		if not nxt:
			print('NO')
			return
		(cur, nxt) = (nxt, {})
		for ((u, d), way) in cur.items():
			newway = way + (u,)
			for v in ww[d]:
				if v != u:
					nxt[v, v - d] = newway
	print('YES')
	for ((u, d), way) in cur.items():
		print(*way[1:] + (u,))
		return
main()


from math import inf as inf
from math import *
from collections import *
import sys
input = sys.stdin.readline
t = 1
while t:
	t -= 1
	a = input().rstrip('\n')
	m = int(input())
	qu = [[-1, 0, 0, []]]
	re = []
	for i in range(10):
		if a[i] == '1':
			re.append(i + 1)
	while qu:
		(x, y, z, r) = qu.pop()
		if z == m:
			print('YES')
			print(*r)
			exit(0)
		for i in re:
			if i != x and i > y:
				qu.append([i, i - y, z + 1, r + [i]])
	print('NO')


from sys import setrecursionlimit
setrecursionlimit(20000)
s = input()
m = int(input())
a = []
for i in range(len(s)):
	if s[i] == '0':
		pass
	else:
		a.append(i + 1)
n = len(a)
arr = []

def count(x, y, k, n):
	global m
	global arr
	if k > m:
		arr.append(y)
		return 1
	f = 0
	for i in range(0, n):
		if x >= 0 and y != a[i] and (x - a[i] < 0):
			f = count(x - a[i], a[i], k + 1, n)
		elif x < 0 and y != a[i] and (x + a[i] > 0):
			f = count(x + a[i], a[i], k + 1, n)
		if f:
			arr.append(y)
			return 1
	return 0
count(0, 0, 1, n)
if arr:
	arr.pop()
	print('YES')
	print(*arr[::-1])
else:
	print('NO')


from collections import defaultdict

def generate_possibilities(m, possibility_matrix, weights, last=0, weight_diff=0):
	if m == 0:
		return True
	if (m, last, weight_diff) in possibility_matrix:
		return possibility_matrix[m, last, weight_diff]
	isPossible = False
	for i in weights:
		if i > weight_diff and i != last:
			isPossible = generate_possibilities(m - 1, possibility_matrix, weights, i, abs(weight_diff - i)) or isPossible
	possibility_matrix[m, last, weight_diff] = isPossible
	return possibility_matrix[m, last, weight_diff]
weights = input()
m = int(input())
available_weights = list()
possibility_matrix = defaultdict(lambda : False)
for (idx, i) in enumerate(weights):
	if i == '1':
		available_weights.append(idx + 1)
generate_possibilities(m, possibility_matrix, available_weights)
if possibility_matrix[m, 0, 0]:
	print('YES')
	last = 0
	weight_diff = 0
	for i in range(m - 1, 0, -1):
		for j in available_weights:
			if j != last and j > weight_diff and possibility_matrix[i, j, abs(weight_diff - j)]:
				print(j, end=' ')
				last = j
				weight_diff = abs(weight_diff - j)
				break
	for j in available_weights:
		if j != last and j > weight_diff:
			print(j, end='')
			break
else:
	print('NO')


ans = []

def dfs(bal, m, last, flag):
	x = bal
	if m == te:
		return 1
	for i in w:
		if i == last:
			continue
		if flag:
			x += i
		else:
			x -= i
		if (x > 0 and flag or (x < 0 and (not flag))) and dfs(x, m + 1, i, not flag):
			ans.append(i)
			return 1
		if flag:
			x -= i
		else:
			x += i
	return 0
s = input()
te = int(input())
w = []
for i in range(len(s)):
	if s[i] == '1':
		w.append(i + 1)
dfs(0, 0, 0, 1)
if ans:
	print('YES')
	print(*ans[::-1])
else:
	print('NO')


import sys
sys.setrecursionlimit(1500)
ans = []

def main():
	w = [int(i) for i in input()]
	m = int(input())
	dfs(w, 0, 0, 1, m)
	print('YES\n' + ' '.join([str(i) for i in ans][::-1]) if len(ans) > 0 else 'NO')

def dfs(w, x, y, k, m):
	if k > m:
		return 1
	f = 0
	for i in range(1, 11):
		if w[i - 1] and x >= 0 and (y != i) and (x - i < 0):
			f = dfs(w, x - i, i, k + 1, m)
		elif w[i - 1] and x < 0 and (y != i) and (x + i > 0):
			f = dfs(w, x + i, i, k + 1, m)
		if f:
			ans.append(i)
			return 1
	return 0
main()


import sys
sys.setrecursionlimit(1000000)
x = input()
n = int(input())
L = []
for i in range(len(x)):
	if x[i] == '1':
		L.append(i + 1)

def f(prev, seq, s1, s2, fl, depth):
	if depth == 0:
		print('YES')
		for i in seq:
			print(i, end=' ')
		print()
		exit(0)
		return
	for i in L:
		if i != prev:
			if fl:
				if s1 + i > s2:
					f(i, seq + [i], s1 + i, s2, not fl, depth - 1)
			elif s2 + i > s1:
				f(i, seq + [i], s1, s2 + i, not fl, depth - 1)
f(-1, [], 0, 0, True, n)
print('NO')


a = [i for (i, j) in enumerate(input(), 1) if j == '1']
m = int(input())
q = [(-1, 0, 0, [])]
p = 'NO'
while q:
	(x, y, z, t) = q.pop()
	if z == m:
		p = 'YES\n' + ' '.join(map(str, t))
		break
	for i in a:
		if i != x and i > y:
			q.append((i, i - y, z + 1, t + [i]))
print(p)


import sys
sys.setrecursionlimit(2000)
n = input()
m = int(input())
arr = [i + 1 for i in range(10) if n[i] == '1']
if len(arr) < 1:
	print('NO')
	exit(0)
a = []

def dfs(x, y, k):
	if k > m:
		return 1
	f = 0
	for i in arr:
		if x >= 0 and y != i and (x - i < 0):
			f = dfs(x - i, i, k + 1)
		elif x < 0 and y != i and (x + i > 0):
			f = dfs(x + i, i, k + 1)
		if f == 1:
			a.append(i)
			return 1
	return 0
result = dfs(0, 0, 1)
if result == 1:
	print('YES')
	for i in a[::-1]:
		print(i, end=' ')
else:
	print('NO')


s = input()
ws = [i + 1 for (i, x) in enumerate(s) if x == '1']
m = int(input())
(acc, seq) = ([0, 0], [])

def dfs(u):
	if len(seq) == m:
		print('YES')
		print(' '.join(map(str, seq)))
		return True
	for w in ws:
		if (not seq or w != seq[-1]) and acc[u] + w > acc[1 - u]:
			acc[u] += w
			seq.append(w)
			u = 1 - u
			if dfs(u):
				return True
			u = 1 - u
			acc[u] -= w
			seq.pop(-1)
if not dfs(0):
	print('NO')


s = input()
m = int(input())
n = len(s)
ans = [0] * (m + 4)
f = 0

def dfs(prev, bal, steps):
	global ans
	global f
	if f:
		return
	if steps == m:
		f = 1
		print('YES')
		print(*ans[:m])
		return
	for i in range(bal + 1, 11):
		if s[i - 1] == '1' and prev != i:
			ans[steps] = i
			dfs(i, i - bal, steps + 1)
dfs(0, 0, 0)
if f == 0:
	print('NO')


def run():
	ws = [i for (i, j) in enumerate(input(), 1) if j == '1']
	m = int(input())
	q = [(-1, 0, 0, [])]
	while len(q) != 0:
		(previous, need, index, lst) = q.pop()
		if index == m:
			print('YES')
			print(' '.join(list(map(str, lst))))
			return
		for w in ws:
			if w > need and w != previous:
				q.append((w, w - need, index + 1, lst + [w]))
	print('NO')
	return
run()


R = lambda : map(int, input().split())
ws = [i + 1 for (i, x) in enumerate(map(int, input())) if x]
m = int(input())
acc = [0, 0]
seq = []
idx = 0

def dfs(acc, seq, idx):
	if len(seq) == m:
		print('YES')
		print(' '.join(map(str, seq)))
		return 1
	for w in ws:
		if (not seq or w != seq[-1]) and acc[idx] + w > acc[1 - idx]:
			acc[idx] += w
			seq.append(w)
			idx = 1 - idx
			if not dfs(acc, seq, idx):
				idx = 1 - idx
				acc[idx] -= w
				seq.pop(-1)
			else:
				return 1
if not dfs(acc, seq, idx):
	print('NO')


from sys import setrecursionlimit
setrecursionlimit(2000)
weights = input()
m = int(input())
l = [x + 1 for x in range(len(weights)) if weights[x] == '1']
sol = []

def solve(x, m, diff):
	if m == 0:
		return True
	for p in l:
		if p > diff and p != x:
			sol.append(p)
			if solve(p, m - 1, p - diff):
				return True
			sol.pop()
	return False
if solve(0, m, 0):
	print('YES')
	for x in sol:
		print(x, end=' ')
else:
	print('NO')


from sys import stdin
from collections import defaultdict
import sys
sys.setrecursionlimit(15000)

def create_graph(string, m):
	numbers = []
	for i in range(len(string)):
		if string[i] == '1':
			numbers.append(i + 1)
	if m == 1:
		if len(numbers) > 0:
			print('YES')
			print(numbers[0])
			exit()
		else:
			print('NO')
			exit()
	graph = defaultdict(list)
	for i in range(len(numbers)):
		for j in range(i + 1, len(numbers)):
			graph[numbers[i]].append(numbers[j])
			graph[numbers[j]].append(numbers[i])
	return graph

def counter(mod):
	if mod[0] == 0:
		mod[0] = 1
	else:
		mod[0] = 0

def dfs(graph, node, mrr, left, right, ans, mod):
	if mrr[0] == 0:
		print('YES')
		print(*ans)
		exit()
	if mod[0] == 0:
		if left[0] + node > right[0]:
			ans.append(node)
			left[0] += node
			counter(mod)
			mrr[0] -= 1
		else:
			return
	elif right[0] + node > left[0]:
		ans.append(node)
		right[0] += node
		counter(mod)
		mrr[0] -= 1
	else:
		return
	for i in graph[node]:
		dfs(graph, i, mrr[:], left[:], right[:], ans[:], mod[:])

def simulate(graph, mrr):
	left = [0]
	right = [0]
	mod = [0]
	ans = []
	for i in graph:
		if mrr[0] > 0:
			dfs(graph, i, mrr[:], left[:], right[:], ans[:], mod[:])
	else:
		print('NO')
		exit()
string = list(stdin.readline().strip())
m = int(stdin.readline().strip())
graph = create_graph(string, m)
mrr = [m]
simulate(graph, mrr)


def main():
	alpha = 'abcdefghijklmnopqrstuvwxyz'
	ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	inf = 1e+17
	mod = 10 ** 9 + 7

	def factorial(n):
		f = 1
		for i in range(1, n + 1):
			f = f * i % mod
		return f

	def ncr(n, r):
		num = den = 1
		for i in range(r):
			num = num * (n - i) % mod
			den = den * (i + 1) % mod
		return num * pow(den, mod - 2, mod) % mod

	def solve(s, m):
		queue = [[0, 0, 0, []]]
		while queue:
			(diff, last, taken, answer) = queue.pop()
			if taken == m:
				print('YES')
				print(' '.join(list(map(str, answer))))
				return
			for opt in s:
				if opt != last and opt - diff > 0:
					queue.append([opt - diff, opt, taken + 1, answer + [opt]])
		print('NO')
		pass
	t = 1
	ans = []
	for _ in range(t):
		s = input()
		s_ = []
		for i in range(len(s)):
			if s[i] == '1':
				s_.append(i + 1)
		m = int(input())
		ans.append(solve(s_, m))
import sys, threading
import bisect
import math
import itertools
from sys import stdout
import heapq
from queue import PriorityQueue
input = sys.stdin.readline
thread = threading.Thread(target=main)
thread.start()
thread.join()


import time, math, bisect, sys
sys.setrecursionlimit(100000)
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x))

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 9 + 7

def recursion(balance, prev_weight, steps_done, m, ans, weights):
	if steps_done == m:
		return True
	else:
		for w in weights:
			if w == prev_weight or abs(balance) >= w:
				continue
			elif (steps_done + 1) % 2 != 0:
				stm = recursion(balance + w, w, steps_done + 1, m, ans, weights)
			else:
				stm = recursion(balance - w, w, steps_done + 1, m, ans, weights)
			if stm:
				ans[steps_done + 1] = w
				return True
		else:
			return False

def solve():
	s = input()
	m = II()
	weights = []
	for i in range(10):
		ele = s[i]
		if ele == '1':
			weights.append(i + 1)
	ans = [0] * (m + 1)
	stm = recursion(0, 0, 0, m, ans, weights)
	if stm:
		print('YES')
		print(*ans[1:])
	else:
		print('NO')
solve()


import sys
sys.setrecursionlimit(100000)
f = sys.stdin
w = f.readline().strip()
m = int(f.readline())
weight = []
for i in range(len(w)):
	if w[i] == '1':
		weight.append(i + 1)

def solve(arr=[], last=-1, delta=0):
	if len(arr) == m:
		print('YES')
		print(*arr)
		exit(0)
	else:
		for i in weight:
			if i != last:
				if delta >= 0 and delta - i < 0:
					solve(arr + [i], i, delta - i)
				elif delta < 0 and delta + i > 0:
					solve(arr + [i], i, delta + i)
solve()
print('NO')


import sys
sys.setrecursionlimit(1000000)
s = input()
a = []
for i in range(10):
	if s[i] == '1':
		a.append(i + 1)
n = int(input())
if len(a) == 0 or (len(a) == 1 and n > 1):
	print('NO')
	exit()
if n == 1:
	print('YES')
	print(a[0])
	exit()
from itertools import combinations
from random import shuffle

def dp(ans, d, prev):
	if len(ans) == n:
		print('YES')
		print(*ans)
		exit()
	for i in a:
		if i != prev and d >= 0 and (i > d):
			dp(ans + [i], d - i, i)
		elif i != prev and d < 0 and (i + d > 0):
			dp(ans + [i], i + d, i)
dp([], 0, -1)
print('NO')


def solve(a, b, m, M, weights, last, solution):
	if a - b > 10:
		return False
	if m == M:
		print('YES')
		print(*solution)
		return True
	for w in weights:
		if w != last and b + w > a:
			solution[m] = w
			if solve(b + w, a, m + 1, M, weights, w, solution):
				return True
	return False
import sys
sys.setrecursionlimit(1500)
w = input()
m = int(input())
weights = []
for i in range(1, 11):
	if w[i - 1] == '1':
		weights.append(i)
weights.sort(reverse=True)
solution = [0 for x in range(0, m)]
if not solve(0, 0, 0, m, weights, -1, solution):
	print('NO')


import sys
sys.setrecursionlimit(100000)
list_weights = []

def gen(ans=[], last=list_weights, delta=0):
	if len(ans) == m:
		print('YES')
		print(*ans)
		exit(0)
	for k in list_weights:
		if k != last:
			if delta >= 0 and delta - k < 0:
				gen(ans + [k], k, delta - k)
			elif delta < 0 and k + delta > 0:
				gen(ans + [k], k, delta + k)
weights = list(map(int, list(input())))
m = int(input())
for i in range(10):
	if weights[i]:
		list_weights.append(i + 1)
gen()
print('NO')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
from collections import deque

def main():
	weights = set()
	inputWeights = input()
	for i in range(10):
		if inputWeights[i] == '1':
			weights.add(i + 1)
	balance = 0
	lastWeight = 1
	step = 2
	previousNode = 3
	m = int(input())
	stack = [(0, 0, 0, None)]

	def addToQueue(current, weight, sign):
		stack.append((current[balance] + weight * sign, weight, current[step] + 1, current))

	def printResults():
		sequence = [0] * m
		current = stack[-1]
		i = m - 1
		while current[lastWeight]:
			sequence[i] = current[lastWeight]
			current = current[previousNode]
			i -= 1
		print('YES')
		print(' '.join(map(lambda x: str(x), sequence)))
	while len(stack) > 0:
		current = stack.pop()
		for weight in weights:
			if weight != current[lastWeight]:
				if current[step] + 1 & 1:
					if current[balance] + weight > 0:
						addToQueue(current, weight, 1)
						if current[step] + 1 == m:
							printResults()
							return
				elif current[balance] - weight < 0:
					addToQueue(current, weight, -1)
					if current[step] + 1 == m:
						printResults()
						return
	print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
input = lambda : sys.stdin.readline().rstrip('\r\n')

def print(*args, **kwargs):
	sep = kwargs.pop('sep', ' ')
	file = kwargs.pop('file', sys.stdout)
	atStart = True
	for x in args:
		if not atStart:
			file.write(sep)
		file.write(str(x))
		atStart = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
main()


def solve(ans, flag, sum_a, sum_b):
	if len(ans) == m + 1:
		return ans
	for w in ww:
		if flag == 0:
			if sum_a + w > sum_b and ans[-1] != w:
				ans.append(w)
				sum_a += w
				dd = solve(ans, 1, sum_a, sum_b)
				if dd != []:
					return ans
				sum_a -= w
				ans.pop()
		elif flag == 1:
			if sum_b + w > sum_a and ans[-1] != w:
				ans.append(w)
				sum_b += w
				dd = solve(ans, 0, sum_a, sum_b)
				if dd != []:
					return ans
				sum_b -= w
				ans.pop()
	return []
s = input()
m = int(input())
ww = []
for i in range(len(s)):
	if s[i] == '1':
		ww.append(i + 1)
res = solve([0], 0, 0, 0)
res = res[1:]
if len(res) == 0:
	print('NO')
else:
	print('YES')
	for num in res:
		print(num, end=' ')