#include<bits/stdc++.h>
using namespace std;
string s,a,b,s2;
int main(){
getline(cin,s);
cin>>a>>b;
for(int i=0;i<s.size();i++){
if(s[i]!=' ') s2=s2+s[i];
else{
if(s2==a)cout<<b<<" ";
else cout<<s2<<" ";
s2="";
}
}
if(s2==a)cout<<b<<" ";
else cout<<s2<<" ";
return 0;
}