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