Secretary
The secretary of ACMCZ has to write lots of letters: advertisements of trips, invitations, announcements, calling for participants, and also the letters to apology for bad meals, hotel swimming pool under reconstruction, or closed Internet Cafe in the venue of the trip. The computer and the text processor MS Byte is used for writing such letters. The director of the company would like to make work of the young secretary as simple as possible, because he would like to use her services also for some other activities. His proposal is based on an idea that the tesaurus of words used in the letters written by the secretary is limited. There is no problem to make a list of all the used words and the secretary can write only the beginning of each word, so she can eliminate writing a lot of characters. You have to write the program which will change this shortened text into the full version.
Input Specification
At the first line there is a positive integer N stating the number of
assignments to follow. Each assignment consists of two parts. First part
are the words which are known by the secretary, second are the
beginnings of words to be completed. At the first line of the first part
there is a positive integer X, stating the number of words known by
the secretary. Then X lines follow, each of them containing exactly
one word. No word appears more than once in every list. The first line
of the second part contains the positive integer Y. Then Y lines
follow, each containing one string -- the beginning of some word to be
complete.
Each word may be from 1 to 100 characters long and it can contain
upper- and lower-case letters and digits. The total number of known
words (X) is among the interval \<1,1000\>. The Number of uncomplete
words (Y) is among the interval \<1,10000\>. The upper- and lower-case
letters are consider to be different.
Output Specification
For each beginning of the word there must be exactly one line of output.
If it is possible to complete the given string to a unique existing word
from the first part of the assignment, output the sentence
"Doplneno slovo ``XX``." (Completed to word XX), where XX is the
full word. If there are more than one word which could be completed,
output the sentence "Detekovana kolize." (Collision detected).
Finally, if there is no word beginning with the given string, output the
sentence "Slovo nelze doplnit." (Word cannot be completed). It is
also possible to complete the word by an empty string.
Sample Input
1 5 skola skolnik skoda volkswagen voltamper 10 sko skod skop skoln skolni skolnikovo v volper volk volt
Output for Sample Input
Detekovana kolize. Doplneno slovo skoda. Slovo nelze doplnit. Doplneno slovo skolnik. Doplneno slovo skolnik. Slovo nelze doplnit. Detekovana kolize. Slovo nelze doplnit. Doplneno slovo volkswagen. Doplneno slovo voltamper.
![]()