#C3959. Spam Message Sanitizer

    ID: 47443 Type: Default 1000ms 256MiB

Spam Message Sanitizer

Spam Message Sanitizer

You are given a message and a list of spam words. Your task is to replace every occurrence of a spam word in the message with a sequence of asterisks ('*') whose length is exactly the same as that spam word. Matches should only occur when the spam word appears as a complete word (i.e. has a word boundary on each side). The matching is case sensitive.

Formally, for each spam word \(w\) with length \(|w|\), every occurrence of \(w\) in the message that satisfies the word boundary condition must be replaced by \(\underbrace{**\cdots*}_{|w|}\).

Example: For the input message "This product is amazing and you can buy it now at a discount!" and spam words ["product", "buy", "discount"], the output should be "This ******* is amazing and you can *** it now at a ********!".

inputFormat

The input is read from stdin and has the following format:

  1. The first line contains the original message (a string).
  2. The second line contains an integer \(n\) representing the number of spam words.
  3. The next \(n\) lines each contain a spam word.

outputFormat

Output the sanitized message to stdout as a single line.

## sample
This product is amazing and you can buy it now at a discount!
3
product
buy
discount
This ******* is amazing and you can *** it now at a ********!