#C13390. Replace Characters in a String
Replace Characters in a String
Replace Characters in a String
Given a string ( s ) and a list of replacement rules, your task is to create a new string where each occurrence of a character ( a ) in ( s ) is replaced with another character ( b ) as specified by the replacement rule ( (a, b) ). The replacement rules will not cascade; each character in the original string is checked only once.
For example, if ( s = \texttt{"hello world"} ) and the replacement rules are ( [('h', 'H'), ('e', '3'), ('l', '1'), ('o', '0'), ('d', '!')] ), then the resulting string should be ( \texttt{"H3110 w0r1!"} ).
inputFormat
The input is given via standard input (stdin) and consists of multiple lines. The first line contains the string ( s ). The second line contains an integer ( n ) representing the number of replacement rules. Each of the following ( n ) lines contains two space-separated characters: the character to be replaced and the character to replace it with.
outputFormat
Output the modified string after applying the replacement rules to all characters of the input string. The output should be printed to standard output (stdout).## sample
hello world
5
h H
e 3
l 1
o 0
d !
H3110 w0r1!