#include <stdio.h>
#include <string.h>
int main()
{
char a[205];
char c[105],d[105];
char *e;
int i = 0;
gets(a);
gets(c);
gets(d);
e = strtok(a," ");
while(e != NULL){
if(strcmp(e,c) == 0){
printf("%s",d);
}else{
printf("%s",e);
}
e = strtok(NULL," ");
if(e != NULL){
printf(" ");
}
}
return 0;
}