#include using namespace std; int v[100000],k; int main() { int n=1,c1,c2,i,x,j; while(n>=0) { k=1; scanf("%d%d%d",&n,&c1,&c2); x=n; if(n==0 && c1==0 && c2==0) return 0; if(n==c1) printf("%d",c2); while(x>0) { v[k]=x%10; k++; x=x/10; } j=k-1; for(i=k-1; i>=1; i--) if(v[i]>-1) { if(v[i]==c1) v[i]=c2; } while(v[j]==0) { v[j]=-1; j--; } for(i=k-1; i>=1; i--) if(v[i]>-1) printf("%d",v[i]); printf("\n"); } }