Consonants and vowels P49889


Statement
 

pdf   zip

html

Write a program that reads n consonants and n vowels, and prints all the words that can be made up by using each letter exactly once. The words must begin with a consonant, and alternate consonants and vowels. In this exercise, we will assume that ‘y’ is a vowel.

Input

Input consists of a natural number n between 1 and 6, followed by n different consonants and n different vowels. Both consonants and vowels are given in alphabetical order.

Output

Print the words that can be made up with the 2n given letters, starting with a consonant and always alternating consonants and vowels. Print the words in alphabetical order, one per line.

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
    y
    

    Output

    by
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python Python
    User solutions
    C++ Python