All Tracks Data Structures Hash Tables Basics of Hash Tables Problem

Bob - An Idiot !
/

Data Structures, Hash Maps

Problem
Editorial
Analytics

Andi and Bob were friends since childhood days. But, as they grew up Bob started behaving weird and this used to irritate Andi. Once, while Andi took a break after typing a large program Bob came from nowhere and swapped some alphabet keys on Andi's keyboard.

Andi got very angry on seeing this and decided to end their friendship once forever. As we all know Bob is very good at heart and never does anything wrong intentionally. He decided to type the remaining program with the same keyboard Configuration. Given the original fragment of the code that Bob needs to type, You need to tell Bob the code that he should type to get the original code as output.

Help him saving his friendship with Andi.

INPUT :

First line of the input contains a single integer N denoting the number of swaps done by Bob. Next N lines contain a pair of characters A,B denoting the characters which are swapped by Bob (Note that Bob performs these swaps in the given order). From the very next line of input the remaining fragment of the code starts and ends with an end of file character.

OUTPUT:

print the fragment of the program that Bob types.

CONSTRAINTS:

1 <= N <= 106

1 <= |length of codefragment| <= 106

code fragment contains uppercase and lowercase english alphabets only and space.

A,B belongs to Alphabet set (both upper case and lower case letters are included).

SAMPLE INPUT
1
W H
WelloHorld
SAMPLE OUTPUT
HelloWorld
Explanation

For the given test case:

Letter W is swapped with the letter H. So, to type WelloHorld Bob must type HelloWorld on Andi's keyboard.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?