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