#include #include using namespace std; int c1,c2,z,y,c,i,n; char s1[10]; int main() { // freopen("input","r",stdin); // freopen("output","w",stdout); while(1) { scanf("%s",&s1); scanf("%d %d\n",&c1,&c2); if(c1==0&&c2==0&&s1[0]==48&&s1[1]==0)break; n=strlen(s1)-1; for(i=0;i<=n;i++) { c=s1[i]-48; if(c==c1)s1[i]=c2+48; } z=0; for(i=0;i<=n;i++) { c=s1[i]-48; if(c!=0){z=1;printf("%d",c);} else if(c==0&&z==1)printf("0"); } printf("\n"); } return 0; }