from itertools import combinations_with_replacement

s,n = input().split()

for j in (combinations_with_replacement(sorted(s), int(n))):
    print(''.join(j))
55289186223845fca1c024642298e4bc66dd7965
<mask token>

<mask token>
for j in combinations_with_replacement(sorted(s), int(n)):
    print(''.join(j))

<mask token>
s, n = input().split()
for j in combinations_with_replacement(sorted(s), int(n)):
    print(''.join(j))

from itertools import combinations_with_replacement
s, n = input().split()
for j in combinations_with_replacement(sorted(s), int(n)):
    print(''.join(j))

from itertools import combinations_with_replacement

s,n = input().split()

for j in (combinations_with_replacement(sorted(s), int(n))):
    print(''.join(j))