#Q61. 「一本通 2.4 练习 2」Censoring

「一本通 2.4 练习 2」Censoring

Description

Original source: USACO 2015 Feb. Gold

There is a string SS with a length not exceeding 10510^5. Farmer John wants to delete nn forbidden words (a forbidden word may appear multiple times) from SS, denoted as t1tnt_1\sim t_n.

FJ searches for forbidden words in SS 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 SS. Note that deleting a word may cause another forbidden word to appear in SS. These nn forbidden words are designed such that no word is a substring of another, meaning the starting positions of each forbidden word in SS are distinct. Please help FJ complete these operations and output the final SS.

Input Format

The first line contains a string SS;
The second line contains an integer nn;
The next nn lines each contain a string, where the ii-th line contains the string tit_i.

Output Format

A single line containing the modified SS after all operations. It is guaranteed that SS will not become an empty string.

Sample 1

begintheescapexecutionatthebreakofdawn
2
escape
execution

beginthatthebreakofdawn

Data Range and Hints

For all data, 1ti105,1S1051\le \sum |t_i|\le 10^5,1\le |S|\le 10^5. It is guaranteed that all strings consist only of lowercase letters.