Consonants and vowels P78898


Statement
 

pdf   zip

html

Your task is to write a program that reads n consonants and n 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 n between 1 and 5, followed by n different consonants and n 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 2n 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

Public test cases
  • Input

    3
    mpt
    aeo
    

    Output

    mapeto
    mapote
    matepo
    matope
    mepato
    mepota
    metapo
    metopa
    mopate
    mopeta
    motape
    motepa
    pameto
    pamote
    patemo
    patome
    pemato
    pemota
    petamo
    petoma
    pomate
    pometa
    potame
    potema
    tamepo
    tamope
    tapemo
    tapome
    temapo
    temopa
    tepamo
    tepoma
    tomape
    tomepa
    topame
    topema
    
  • Input

    2
    cs
    ao
    

    Output

    caso
    cosa
    saco
    soca
    
  • Input

    1
    b
    u
    

    Output

    bu
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++