#C2527. Moderate Chat Messages

    ID: 45853 Type: Default 1000ms 256MiB

Moderate Chat Messages

Moderate Chat Messages

This problem requires you to moderate chat messages by replacing any inappropriate word with asterisks (*) so that the length of the word is preserved. The comparison is case-insensitive. For example, if the inappropriate word is bad and it appears as "BAD" or "bad" in the text, you should replace it with "***".

The input consists of an integer n representing the number of inappropriate words, followed by a line containing n inappropriate words. Next, an integer m is given representing the number of messages, followed by m lines where each line is a message.

You should output the moderated messages, each on a new line.

Note: The moderation is done by matching whole words exactly (case-insensitively) and replacing them with a sequence of asterisks whose length equals the length of the word.

inputFormat

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

n
w1 w2 ... wn
m
message1
message2
...
message_m

Where:

  • n is the number of inappropriate words.
  • The next line contains n inappropriate words separated by spaces.
  • m is the number of messages.
  • The following m lines each contain a message.

outputFormat

Output m lines to standard output, each line is a moderated message where every inappropriate word has been replaced by a sequence of asterisks whose length equals the original word’s length.

## sample
3
bad ugly nasty
5
This is a bad word!
Such an ugly behavior.
This message is clean.
Another nasty comment.
Nothing inappropriate here.
This is a *** word!

Such an **** behavior. This message is clean. Another ***** comment. Nothing inappropriate here.

</p>