#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
string s;
getline(cin, s);
string sou;
string des;
cin >> sou >> des;
//分割句子
vector<string>v;
int pos = 0;
while (true) {
string temp = s.substr(pos, s.find(' ', pos) - pos);
//cout << temp << endl;
v.push_back(temp);
pos = s.find(' ', pos) + 1;
if (pos == s.npos + 1)break;
}
for (int i = 0; i < v.size(); i++) {
if (v[i] == sou) {
v[i] = des;
}
}
//cout << v.size() << endl;
for (int i = 0; i < v.size(); i++) {
cout << v[i] << " ";
}
cout << endl;
return 0;
}