Concatenations (2) P53390


Statement
 

pdf   zip

thehtml

Write a program that, given a word w and a sequence of words s1, …, sn, prints all the ways to obtain w by concatenating all the given words exactly once.

Input

Input consists of a word w, followed by a natural number n > 0, followed by s1, …, sn. The words only include lowercase letters.

Output

Print all the ways to obtain w by concatenating all the given words exactly once. If there is no solution, print a hyphen. Follow the format of the samples.

Information about the checker

You can print the solutions to this exercise in any order.

Public test cases
  • Input

    holahola
    5
    ho l hol a a
    

    Output

    ho+l+a+hol+a
    ho+l+a+hol+a
    hol+a+ho+l+a
    hol+a+ho+l+a
    
  • Input

    patata
    2
    patata pesol
    

    Output

    -
    
  • Input

    papapapapa
    4
    p papa pa apa
    

    Output

    p+apa+papa+pa
    p+apa+pa+papa
    papa+p+apa+pa
    papa+pa+p+apa
    pa+p+apa+papa
    pa+papa+p+apa
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions