403198: GYM101064 E A Word to Trump All
Description
Donald Trump is a terrible person. It is said he won't sleep at night until he has unfairly offended someone. Donald knows N horrible words and M kind words. For his next speech, he wants to compress the horrible words together to create the most offensive word of all time, while not saying any kind words.
We say a word s contains a word t if it has the word t as a contiguous substring. Trump wants to find the smallest word that contais all N horrible words he knows, and none of the M kind words. Determine one such word.
InputOn the first two integers N and M. In each of the next N lines, a horrible word. In each of the next M lines, a kind word.
Limits
- 1 ≤ N + M ≤ 15
- N ≥ 1, M ≥ 0
- Each word is a string with at least 1 and at most 300 characters
- All strings consist of lowercase characters from a to j
- The sum of lengths of all strings will not exceed 300
If there is no such word, print only "-" in a single line. Otherwise, print a single string, an answer to the problem. It can only contain lowercase characters from a to j. If there are multiple possible strings, print any of them.
ExamplesInput3 0Output
hejja
gecab
jag
hejjagecabInput
3 1Output
ababab
bababb
abbb
babbb
abbbabababb