#include <iostream>
#include <sstream>
using namespace std;
string s,a,b;
void Output(){
istringstream sin(s);
string temp;
while(sin>>temp){
if(temp==a) cout<<b<<' ';
else cout<<temp<<' ';
}
return ;
}
void Input(){
getline(cin,s);
getline(cin,a);
getline(cin,b);
return ;
}
int main()
{
Input();
Output();
return 0;
}