while 1: s=raw_input().split();t=s[0] for a,b in s[1:]:t=t.replace(a," ").replace(b,a).replace(" ",b) print t