#include<cstdio>
using namespace std;
int main()
{


    freopen("ex.in","r",stdin);
    freopen("ex.out","w",stdout);



    int n,c1,c2,r,i,first=false;
    bool viz=false;
    int v[7];


    while(true)
    {
        first=false;
        r=1;
        scanf("%d%d%d",&n,&c1,&c2);


        if(!n)
            break;

        if(n&&viz)
        {
            printf("\n");
        }



        while(n>0)
        {

            if(n%10==c1)
            {
                v[r]=c2;
            }
            else
            {

                v[r]=n%10;

            }
            ++r;
            n/=10;

        }

        for(i=r-1; i>0; --i)
        {
            if(v[i]>0)
                first=true;
            if(first)
            {
                viz=true;
                printf("%d",v[i]);
            }
        }




    }
}