#55018: [python]解法


jason.fu305@gmail.com (Jason Fu)


from itertools import permutations

while True:
    try:
        s = 'abcdefg'
        n = int(input())
        if n == 0:
            break
        
        perm = permutations(s[:n])

        for i in perm:
            print(''.join(i))

    except:
        break