#include <cstdio>
#include <cstring>

using namespace std;

#define BSIZE 65536

int p,t,i,c1,k,c2;
char str[BSIZE];

int main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif

while (!(str[0]=='0' && k==1 && c1==0 && c2==0))
{
    scanf("%s",str);

    k=strlen(str);

    scanf("%d %d",&c1,&c2);

    for (i=0;i<k;++i)
    if (str[i]==c1+'0') str[i]=c2+'0';

    i=0;
    while (str[i]=='0') ++i;

    for (;i<k;++i)
    printf("%c",str[i]);

    printf("\n");
}

return 0;
}