Consonants and vowels

Your task is to write a program that reads nn consonants and nn vowels, and that prints all the words that can be formed using exactly once each one of the given letters. The words have to start in consonant, and must alternate consonants and vowels.

Input

The input consists of a natural nn between 1 and 5, followed by nn different consonants and nn different vowels. The consonants as well as the vowels are given in alphabetical order.

Output

Your program must print all the words that can be formed with the 2n2n given letters, starting in consonant and alternating consonants and vowels. The words must be written in alphabetical order, one per line. Logically, it is not necessary that the generated words have any meaning.

Author: Salvador Roura

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:01:10.501Z

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