#K55797. Replace Specific Word

    ID: 30055 Type: Default 1000ms 256MiB

Replace Specific Word

Replace Specific Word

You are given a list of words and a replacement string. Your task is to replace every occurrence of the word replace (case-sensitive) in the list with the given replacement string. Note that only the word that exactly matches replace should be replaced. Words that contain extra characters (for example, punctuation) are not considered a match and should remain unchanged.

For example, if the input list is ["this", "is", "a", "replace"] and the replacement string is "substitute", the output should be ["this", "is", "a", "substitute"].

Make sure to read the input from standard input (stdin) and output your result to standard output (stdout). The words in the output should be printed in the same order as they appear in the input, separated by a single space.

inputFormat

The first line contains a single integer n (1 ≤ n ≤ 1000) representing the number of words. The second line contains n words separated by spaces. The third line contains a single word which is the replacement string.

outputFormat

Output the modified list of words in a single line, where each word is separated by a single space.## sample

4
this is a replace
substitute
this is a substitute