#include <iostream>

using namespace std;

int qw[100],n,c1,c2;

int think(int n,int a,int b)
{
    int i=0;

    if(n==0)
    {
        if(a==n)
            cout<<b;
        else
            cout<<n;

    }

    while(n!=0)
    {
        i++;
        qw[i]=n%10;
        if(n%10==a)
           qw[i]=b;
        n/=10;
    }
    qw[0]=i;
    while(qw[i]==0 && i>1)
        i--;


    for(int j=i;j>=1;j--)
        cout<<qw[j];

    cout<<'\n';
    return 0;
}



int main()
{
    while(true)
    {
        cin>>n>>c1>>c2;
        if(n==c1 && c1==c2 && n==0)
            break;
        think(n,c1,c2);
    }

     return 0;
}