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 n could be formed with m given letters?

Input

Input consists of several cases, each with n and m, followed by m
different lowercase letter. It holds that n ≥ 1, 2 ≤ m ≤ 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 n that
can be built with the m 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
