#include <iostream>
#include <sstream> // 有stringstream 需要放
using namespace std;
int main()
{
string s, a, b, c;
getline(cin, s);
cin >> a >> b;
stringstream ssin(s); // 将读入的stream流转换成stringstream对象:ssin
while(ssin >> c) // ssin的读入同cin
if(c == a) cout << b << " ";
else cout << c << " ";
return 0;
}