#include using namespace std; int main(){ long n; short c1,c2,v[10],l,i; bool ok; while(1){ cin>>n; cin>>c1; cin>>c2; if(!n && !c1 && !c2) break; l=0; while(n){ v[++l]=n%10; n/=10; } for(i=1;i<=l;i++){ if(v[i]==c1) v[i]=c2; } ok=0; for(i=l;i>=1;i--){ if(!v[i] && !ok) continue; if(v[i]) ok=1; cout<