#include<iostream>
#include<sstream>
using namespace std;
int main(){
string s,a,b;
getline(cin,s);
cin>>a>>b;
stringstream ssin(s);//讲字符串s初始化为字符串流
string str;
while(ssin>>str){//讲ssin当cin用
if(str==a) cout<<b<<" ";
else cout<<str<<" ";
}
return 0;
}