Ruins

Recent excavations have revealed an ancient extinct language. Thanks to the ruins found, experts have deduced that there were vowels and consonants, and that all words could be formed, with one sole exception: a word could not have two or more consecutive vowels. For example, with the two vowels a and e, and consonant b, 11 words with three letters could be formed: aba, abb, abe, bab, bba, bbb, bbe, beb, eba, ebb, ebe.

Which words of size nn could be formed with mm given letters?

Input

Input consists of several cases, each with nn and mm, followed by mm different lowercase letter. It holds that n1n \ge 1, 2m262 \le m \le 26, and that each case has at least one vowel and one consonant.

Output

For each case, write in lexicographical order all words of length nn that can be built with the mm given letters. Write a line with 10 hyphens after each case.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T14:07:49.966Z

© Jutge.org, 2006–2026.
https://jutge.org