#include <bits/stdc++.h>
using namespace std;

int main() {
    string s,target,replacer;
    while(getline(cin,s)){
        //输入
        cin>>target>>replacer;
        //划分单词
        vector<string>v;
        string temp="";
        for(int i=0;i<s.length();i++){
            if(s[i] == ' '){
                v.push_back(temp);
                temp = "";
            }else if(i == s.length()-1){
                temp+=s[i];
                v.push_back(temp);
                break;
            }else{
                temp+=s[i];
            }
        }
        for(int i =0;i<v.size();i++)
            if(v[i] == target)
                v[i] = replacer;
        for(auto a:v)
            cout<<a<<" ";
    }
}
// 64 位输出请用 printf("%lld")

缝缝补补