from itertools import combinations
inputStr, k = input().split()
k = int(k)
inputStr = sorted(str(inputStr))
results = []
for length in range(1, k + 1):
    currResults = []
    combos = list(combinations(inputStr, length))
    for i in combos:
        currResults.append(''.join(i))
    currResults.sort()
    results.extend(currResults)
for i in results:
    print(i)

06edcb2d42509d8d43723ed282c54f93975b78ce
<mask token>

<mask token>
for length in range(1, k + 1):
    currResults = []
    combos = list(combinations(inputStr, length))
    for i in combos:
        currResults.append(''.join(i))
    currResults.sort()
    results.extend(currResults)
for i in results:
    print(i)

<mask token>
inputStr, k = input().split()
k = int(k)
inputStr = sorted(str(inputStr))
results = []
for length in range(1, k + 1):
    currResults = []
    combos = list(combinations(inputStr, length))
    for i in combos:
        currResults.append(''.join(i))
    currResults.sort()
    results.extend(currResults)
for i in results:
    print(i)

from itertools import combinations
inputStr, k = input().split()
k = int(k)
inputStr = sorted(str(inputStr))
results = []
for length in range(1, k + 1):
    currResults = []
    combos = list(combinations(inputStr, length))
    for i in combos:
        currResults.append(''.join(i))
    currResults.sort()
    results.extend(currResults)
for i in results:
    print(i)
