#include<iostream>
#include<sstream>
using namespace std;
int main(){
string a,b;
string c;
getline(cin,a);
cin>>b>>c;
stringstream ssin(a);
string str;
while(ssin>>str){
if(str==b)cout<<c<<' ';
else cout<<str<<" ";
}
}