#include<iostream>
#include<sstream>
using namespace std;
int main(){
string s, a, b;
getline(cin, s);
cin >> a >> b;
stringstream ssin(s);
string d;
while(ssin >> d){
if(d == a)
cout << b << " ";
else
cout << d << " ";
}
return 0;
}