#include <iostream>
#include <sstream>
using namespace std;
int main()
{
string s,a,b;
getline(cin,s);
stringstream ss = stringstream(s); // 初始化流
cin >> a>>b;
while(ss >> s)
{
if(s==a) cout<<b<<" ";
else cout<<s<<" ";
}
}