Broken palindromes P54747


Statement
 

pdf   zip

html

(The original statement in Catalan has some jokes. This English version goes straight to the point of the problem.)

A palindrome has been broken into pieces. Put the pieces together in the right order.

Input

Input consists of several cases. Every case begins with the number of pieces n. Follow the n pieces, made up of only lowercase letters. Assume 1 ≤ n ≤ 8.

Output

For every case, print the palindrome that can be made by joining all the pieces. There is always exactly one solution.

Public test cases
  • Input

    8
    da
    ba
    learro
    zal
    azo
    rra
    ela
    bad
    3
    b
    a
    a
    2
    votemos
    someto
    1
    pop
    

    Output

    dabalearrozalazorraelabad
    aba
    sometovotemos
    pop
    
  • Information
    Author
    Alex Alvarez
    Language
    English
    Translator
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++