#include<bits/stdc++.h>
using namespace std;
string s;
string a,b;
string t[110];
int main(){
getline(cin,s);
cin>>a;
cin>>b;
int h=0;
for(int i=0;i<=s.size();i++){
if(s[i]!=' '){
t[h]+=s[i];
}
else{
h++;
}
}
for(int i=0;i<h;i++){
if(t[i]==a){
cout<<b<<" ";
}
else{
cout<<t[i]<<" ";
}
}
return 0;
}