import operator while True: try: line = input().strip().split() word, choose = line[-2:] #读取单词,排列数 word_sort = sorted(word) #排序后的单词 word_num = line[0] #待匹配的单词数 fit_word = [] #符合的单词序列 for i in line[1:-2]: if i == word: continue if operator.eq(word_sort,sorted(i)): fit_word.append(i) fit_word.sort() if len(fit_word) >=int(choose): print(len(fit_word),fit_word[int(choose)-1],sep='\n') else: print(len(fit_word)) #不用输出 except Exception as e: break