#include<string> #include<iostream> using namespace std; int main() { string s1,s2,s3; string n = " "; while (getline(cin, s1)) { getline(cin, s2); getline(cin, s3); while (s1.find(n + s2 + n) != string::npos || s1.find(s2 + n) == 0 || s1.find(n + s2) == s1.size() - s2.size()) { if (s1.find(n + s2 + n) != string::npos) { s1.replace(s1.find(n+s2+n), s2.size()+2, n + s3 + n); } else if (s1.find(s2 + n) == 0) { s1.replace(s1.find(s2 + n), s2.size() + 1, s3 + n); } else s1.replace(s1.find(n + s2), s2.size() + 1, n+s3); } cout << s1 << endl; } return 0; }