public class Main{
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
String[] split = s.split(" ");
String in = br.readLine();
String re = br.readLine();
for (int i = 0; i < split.length; i++) {
if(split[i].equals(in)){
split[i] = re;
}
}
for (String string : split) {
System.out.print(string + " ");
}
}
}