#include<iostream>
#include<sstream>
using namespace std;
int main()
{
string s, a, b;
getline(cin, s);
cin >> a >> b;
stringstream ssin(s);//将字符串初始化为字符串流,此时ssin用法和cin一样
string str;
while(ssin >> str)
{
if(str == a) cout << b << ' ';
else cout << str <<' ';
}
return 0;
}