import random def aaa(): while len(shiritori)<a: c = random.randint(1,18) for i in range(c): b = random.choice("abcdefghijklmopqrstuvwxyz") global word word = word + b if i == c-1: if len(shiritori)==a-1: word = word+'n' setlen = len(shiritori) shiritori.add(word) if len(shiritori)==setlen: word = word[0:1] if len(shiritori)>setlen: print(word) word = b a = int(input()) word = random.choice("abcdefghijklmopqrstuvwxyz") shiritori = set() aaa()