#include <iostream>
#include <string>

using namespace std;

int f, p;
string n, c1, c2;

int main()
{
    while(1){
        cin >> n >> c1 >> c2;
        if(n=="0" && c1=="0" && c2=="0")
            return 0;
        else{
            p=n.find(c1);
            while(p!=-1){
                n.erase(p, 1);
                n.insert(p, c2);
                p=n.find(c1);
            }
        }
            for(int i=0; i<=n.size(); i++)
                if(n[i]=='0')
                    f++;
            if(f==n.size())
                cout << "0";
            else
                cout << n;

    }
    return 0;
}