#include<stdio.h>
#include<string.h>
int main(){
char s[200]={0};
char a[100]={0};
char b[100]={0};
int loc1=0,loc2=0;
int i=0,j=0;
while((s[i++]=getchar())!='\n'){}
scanf("%s",a);
scanf("%s",b);
char c[100]={};
int len1=strlen(s);
int len3=strlen(a);
int len4=strlen(b);
char s1[50][200]={};
int count=0;
if(len3==len4){
for(i=0;i<len1;i++){
if((s[i]==' ')||(s[i]=='\n')){
loc2=i;
for(j=loc1;j<loc2;j++){
c[j-loc1]=s[j];
}
int temp=strcmp(c,a);
if(temp==0){
for(j=loc1;j<loc2;j++){
s[j]=b[j-loc1];
}
}
loc1=i+1;
int len2=strlen(c);
for(j=0;j<len2;j++){
c[j]=0;
}
}
}
printf("%s",s);
}else if((len3>len4)||(len3<len4)){
for(i=0;i<len1;i++){
if((s[i]==' ')||(s[i]=='\n')){
loc2=i;
for(j=loc1;j<loc2;j++){
c[j-loc1]=s[j];
}
int temp=strcmp(c,a);
if(temp==0){
strcpy(s1[count++],b);
}else{
strcpy(s1[count++],c);
}
loc1=i+1;
int len2=strlen(c);
for(j=0;j<len2;j++){
c[j]=0;
}
}
}
for(i=0;i<count;i++){
printf("%s ",s1[i]);
}
}
}