#include <iostream>
using namespace std;
int main(){
string s; getline(cin, s);
string p, other; cin >> p >> other;
string res = "", word = "";
for(int i = 0; i < s.size(); i ++ ){
if(s[i] != ' ') word += s[i];
else{
if(word == p) word = other;
word += ' ', res += word;
word = "";
}
}
if(word == p) word = other;
res += word;
cout << res << endl;
return 0;
}