#Q61. 「一本通 2.4 练习 2」Censoring
「一本通 2.4 练习 2」Censoring
Description
Original source: USACO 2015 Feb. Gold
There is a string with a length not exceeding . Farmer John wants to delete forbidden words (a forbidden word may appear multiple times) from , denoted as .
FJ searches for forbidden words in from the beginning. Once a forbidden word is found, FJ deletes it and then starts searching again from the beginning (rather than continuing from the next position). FJ repeats this process until no forbidden words remain in . Note that deleting a word may cause another forbidden word to appear in . These forbidden words are designed such that no word is a substring of another, meaning the starting positions of each forbidden word in are distinct. Please help FJ complete these operations and output the final .
Input Format
The first line contains a string ;
The second line contains an integer ;
The next lines each contain a string, where the -th line contains the string .
Output Format
A single line containing the modified after all operations. It is guaranteed that will not become an empty string.
Sample 1
begintheescapexecutionatthebreakofdawn
2
escape
execution
beginthatthebreakofdawn
Data Range and Hints
For all data, . It is guaranteed that all strings consist only of lowercase letters.