https://www.acmicpc.net/problem/1759
combinations 사용
from itertools import combinations
import sys
read = sys.stdin.readline
write = sys.stdout.write
l, c = map(int, read().split())
chars = list(read().split())
chars.sort()
모음 = set(['a','e','i','o','u'])
for combi in combinations(chars, l):
count1, count2 = 0, 0
for c in combi:
if c in 모음:
count1 += 1
else:
count2 += 1
if count1 >= 1 and count2 >= 2:
write(f'{"".join(combi)}\n')