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