GFSSOC '14 Winter S2 - Speech

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 16M

Authors:
Problem type

Now that Griffy has a list of who he wants to make friends with, he needs to prepare a speech to win over their friendship! Unfortunately, Griffy is not the best public speaker, so you've agreed to help correct and improve his speech! You have a list of "friendship" words that you would like to replace some "not-so-friendship" words in Griffy's speech with. Given N distinct "friendship" words and the distinct words they will replace, please find out the new and improved speech.

Input Specification

First line: one integer N (0N10).

Lines 2 to N+1: two words space separated: a "friendship" word and a "not-so-friendship" word.

Next line: one string, the speech, up to 100 words long separated by spaces. The string will be terminated with a period.

Note: All words will be at most 20 characters long, composed of lowercase alphabetical characters.

Output Specification

One string, the speech with all "not-so-friendship" words replaced with their "friendship" word counterpart.

Sample Input

Copy
2
hello uh
exactly uhm
uh what uh are uhm you doing uhh.

Sample Output

Copy
hello what hello are exactly you doing uhh.

Comments

There are no comments at the moment.