st = input()[2::].split()
rep = input()
a = 0
for i in range(2):
    rep = rep.replace(st[a],st[a+1])
    a += 2
print(rep)