#include <iostream>
#include <sstream>
using namespace std;

int main() {
    string s,a,b;
    getline(cin,s);
    cin>>a>>b;
    stringstream ssin(s);
    string res,temp;
    while(ssin>>temp){
        if(temp==a) {
            res+=b;
            res+=" ";
        }
        else {
            res+=temp;
            res+=" ";
        }
    }
    cout<<res<<endl;
    return 0;
}
// 64 位输出请用 printf("%lld")