#include <iostream>
#include <string>

using namespace std;

int p;
string n, c1, c2;

int main()
{
    while(n != "0" && c1!="0" && c2!="0"){
        cin >> n >> c1 >> c2;
        p=n.find(c1);
        while(p!=-1){
            n.insert(p, c2);
            n.erase(p+1, 1);
            p=n.find(c1);
        }
        cout << n;
    };
    return 0;
}