import itertools

Alphabet = 'abcd'

def words(S, L):
    return [ ''.join(w) for w in itertools.product(S, repeat=L) ]

R = itertools.chain.from_iterable(words(Alphabet,i) for i in range(1, 6))
print(' '.join(R))