Manthan, Codefest 16
C
Spy Syndrome 2
Codeforces
1900
原题
← BD →
翻译中…

After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't use a cipher as basic and ancient as Caesar cipher. After many weeks of observation of Siddhant’s sentences, Yash determined a new cipher technique.

翻译中…

For a given sentence, the cipher is processed as:

翻译中…
  1. Convert all letters of the sentence to lowercase.
  2. Reverse each of the words of the sentence individually.
  3. Remove all the spaces in the sentence.
翻译中…

For example, when this cipher is applied to the sentence

翻译中…

Kira is childish and he hates losing

翻译中…

the resulting string is

翻译中…

ariksihsidlihcdnaehsetahgnisol

翻译中…

Now Yash is given some ciphered string and a list of words. Help him to find out any original sentence composed using only words from the list. Note, that any of the given words could be used in the sentence multiple times.

翻译中…

Input

翻译中…

The first line of the input contains a single integer $*n*$ ($1 ≤ *n* ≤ 10 000$) — the length of the ciphered text. The second line consists of $*n*$ lowercase English letters — the ciphered text $*t*$.

翻译中…

The third line contains a single integer $*m*$ ($1 ≤ *m* ≤ 100 000$) — the number of words which will be considered while deciphering the text. Each of the next $*m*$ lines contains a non-empty word $*w*_{*i*}$ ($|*w*_{*i*}| ≤ 1 000$) consisting of uppercase and lowercase English letters only. It's guaranteed that the total length of all words doesn't exceed $1 000 000$.

翻译中…

Output

翻译中…

Print one line — the original sentence. It is guaranteed that at least one solution exists. If there are multiple solutions, you may output any of those.

翻译中…

Note

翻译中…

In sample case 2 there may be multiple accepted outputs, "HI there HeLLo" and "HI there hello" you may output any of them.

翻译中…

样例

Input #1
30
ariksihsidlihcdnaehsetahgnisol
10
Kira
hates
is
he
losing
death
childish
L
and
Note
Output #1
Kira is childish and he hates losing
InputCopy OutputCopy
Input #2
12
iherehtolleh
5
HI
Ho
there
HeLLo
hello
Output #2
HI there HeLLo
InputCopy OutputCopy
题目信息
题号
633C
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划
哈希
模拟
排序
后缀结构
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。