s = input().split() a = input() b = input() for i in s: if i == a: print (b, end = " ") else: print (i, end = " ")