Automatic translation P31571


Statement
 

pdf   zip

html

Given n words in one language X, and a text with m words written in another language Y, print all the possible translations of the text to X, assuming that there is a bijection between the words of X and Y.

Input

Input consists of several cases. Every case begins with n, followed by the n words of the language X, in increasing order, each one made up of between one and six lowercase letters. Follow m, followed by the m words of the text written in Y, each one made up of between one and six uppercase letters. This text contains exactly n different words. Assume 1 ≤ n ≤ 6 and nm ≤ 1000.

Output

For every case, print in alphabetical order all the possible translations of the text in Y to X. Print a line with 10 dashes at the end of each case.

Public test cases
  • Input

    2 bye hi
    4 HOLA ADEU ADEU HOLA
    
    4 cat dog fly horse
    8 MOSCA GOS GOS CAVALL GAT GAT GAT GOS
    
    1 one
    3 UN UN UN
    

    Output

    bye hi hi bye
    hi bye bye hi
    ----------
    cat dog dog fly horse horse horse dog
    cat dog dog horse fly fly fly dog
    cat fly fly dog horse horse horse fly
    cat fly fly horse dog dog dog fly
    cat horse horse dog fly fly fly horse
    cat horse horse fly dog dog dog horse
    dog cat cat fly horse horse horse cat
    dog cat cat horse fly fly fly cat
    dog fly fly cat horse horse horse fly
    dog fly fly horse cat cat cat fly
    dog horse horse cat fly fly fly horse
    dog horse horse fly cat cat cat horse
    fly cat cat dog horse horse horse cat
    fly cat cat horse dog dog dog cat
    fly dog dog cat horse horse horse dog
    fly dog dog horse cat cat cat dog
    fly horse horse cat dog dog dog horse
    fly horse horse dog cat cat cat horse
    horse cat cat dog fly fly fly cat
    horse cat cat fly dog dog dog cat
    horse dog dog cat fly fly fly dog
    horse dog dog fly cat cat cat dog
    horse fly fly cat dog dog dog fly
    horse fly fly dog cat cat cat fly
    ----------
    one one one
    ----------
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++