## COCI '16 Contest 2 #2 Tavan

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 32M

Problem type

Little Željko has been reading his grandma's old letters in the attic and has come across a word of length . Unfortunately, he couldn't make out what it said because of the spilled ink. He rewrote the word on a piece of paper by replacing each of the illegible letters with the character #. He handed the piece of paper to his grandma and she gave him different candidates for each of the illegible letters. After that, Željko wrote all the possible words in a notebook and decided to closely look at their properties in order to determine what the original words were. After seeing the words written down in the notebook, his grandma realized that the word they're looking for is the one in alphabetical order. Željko had the sniffles the day they learned the alphabet in school, so he's asking you for your help with determining the original word.

#### Input Specification

The first line of input contains the integers , , and .

The second line of input contains the word of length that Željko wrote on a piece of paper, consisting of lowercase letters of the English alphabet and the character #.

Each of the following lines contains one word of length , the of these words consisting of letters that could replace the illegible letter.

#### Output Specification

The first line of output must contain the word in alphabetical order.

#### Scoring

In test cases worth of total points, it will hold and .

In test cases worth an additional of points, it will hold .

#### Sample Input 1

9 2 3 7
po#olje#i
sol
znu

#### Sample Output 1

posoljeni

#### Explanation for Sample Output 1

The possible words, in alphabetical order, are: pololjeni, pololjeui, pololjezi, poooljeni, poooljeui, poooljezi, posoljeni, posoljeui, posoljezi.

#### Sample Input 2

4 1 2 2
#rak
zm

#### Sample Output 2

zrak