#include <iostream>

using namespace std;

int nr(int x,int c1, int c2)
{
    int uc;
    if(x==0) return 0;
    uc=x%10;
    if(uc==c1) uc=c2;
    return nr(x/10,c1,c2)*10+uc;

}

int main()
{
    int x,c1,c2;
    while (cin>>x)
    {
        cin>>c1>>c2;
        if(x==0&&c2==0&&c1==0) return 0;
        if (x==0&&c1==0&&c2!=0) cout<<c2<<'\n';
        else
        cout<<nr(x,c1,c2)<<'\n';

    }
    return 0;
}