import java.util.Scanner;
public class Main {
public static void main(String args[]){
String s, a, b;
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()){
s = scanner.nextLine();
a = scanner.nextLine();
b = scanner.nextLine();
String temp[] = s.split(" ");
for(int i = 0; i < temp.length; i++){
if(temp[i].equals(a)){
temp[i] = b;
}
}
for (int i = 0; i < temp.length; i++) {
if (i == temp.length - 1) {
System.out.println(temp[i]);
} else {
System.out.print(temp[i] + " ");
}
}
}
}
}