#include <iostream>
#include <string.h>
using namespace std;
char x[6],c1,c2,nr,ok=1;
//int ok=1;
int main()
{   cin>>x;
    cin>>c1>>c2;
    do{

    nr++;


    for(int i=0;i<=strlen(x);i++)
        if(x[i]==c1){
            if(c2!='0' or( i==0 and strlen(x)==1)  or i!=0)
                cout<<c2;
            }
        else cout<<x[i];
    cout<<endl;
    cin>>x;
    cin>>c1>>c2;
    //cout << 73 << endl;
    if(x[0]=='0' && c1=='0' && c2=='0') ok=0;
    }while(ok &&nr<=15);
    return 0;
}