13572 - String Operations 1   

Description

Aftermath, a student in NTHU, is very good at programming. Today, as usual, she comes up with a programming problem but felt bored to solve it by herself(it’s too easy for her!). Thus, she left the problem to you, that is:

Given a string that consists of only lowercase Latin characters, there are Q operations to apply on this string. Each operation is represented by two characters, let’s say A and B, and you have to turn every A in the given string to B. After the Q operations, you should print the resulting string in one line(remember to print a new line character).

Input

The first line contains a string s, which consists of only lowercase Latin characters. The second line contains a integer Q. The next Q lines, each contains two characters A and B.

Constraints

  • 1≤|s|≤106
  • 1≤Q≤105
  • A,B∈[a−z]

for testcases 1~3, 1≤|s|≤1000.

for testcases 4~6, there’s no additional constraints.

Output

Print the resulting string in one line after applying the Q operations.

(remember to print a new line character)

Sample Input  Download

Sample Output  Download

Tags

LoseLightLight



Discuss