#include <stdio.h>
#include <string.h>
int main(){
char s[100], a[100], b[100];
char *temp;
while(gets(s)){
scanf("%s", a);
scanf("%s", b);
temp = strtok(s, " ");
while(temp){
if(strcmp(temp, a) == 0){
printf("%s", b);
}else{
printf("%s", temp);
}
temp = strtok(NULL," ");
if(temp){
printf(" ");
}
}
printf("\n");
getchar();
}
return 0;
}