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