#include using namespace std; int v[100]; int main() { //FILE *fin, *fout; int c1,c2,nr,i,k; //fin=fopen("nc1c2.in","r"); //fout=fopen("nc1c2.out","w"); c1=nr=c2=-1; while(c1!=0||c2!=0||nr!=0) { i=0; scanf("%d%d%d",&nr,&c1,&c2); while(nr>0) { v[i]=nr%10; nr/=10; ++i; } k=i-1; while(k>-1&&v[k]==c1&&c2==0) --k; while(k>-1) { if(v[k]==c1&&(c2!=0||(c2==0&&k!=i-1))) printf("%d",c2); else printf("%d",v[k]); --k; } printf("\n"); } return 0; }