https://www.acmicpc.net/problem/1759
"""
"""
from itertools import combinations
from sys import stdin
input = stdin.readline
l, c = map(int, input().split())
lst = list(input().split())
lst.sort() # 문제에서 알파벳이 암호에서 증가하는 순으로 배치한다고 언급
answer = list(combinations(lst, l)) # 조합 이용
remove_index = []
for i in range(len(answer)): # 만약 자음이 2개 미만이거나 모음이 1개 미만인경우 삭제한다.
consonant, vowel = 0, 0
for j in answer[i]:
if j in ('a', 'e', 'i', 'o', 'u'):
vowel += 1
else:
consonant += 1
if consonant < 2 or vowel < 1:
remove_index.append(i)
for i in range(len(answer)): # 자음 2개미만, 모음 1개미만이 아닌 경우에만 공백을 join으로 삭제하면서 출력한다.
if i not in remove_index:
print(''.join(answer[i]))
골드5 문제이지만 문제 설명 그대로 구현하면 쉬운 문제