#include using namespace std; int rasturnat (int n) { int p=0; while(n>0) { p=p*10+n%10; n=n/10; } return p; } int schimb(int n,int a,int b) { int c=0; n=rasturnat(n); while(n>0) { if(n%10==a) c=c*10+b; else c=c*10+n%10; n=n/10; } return c; } int main() { int n,c1,c2; while(n>0) { scanf("%d%d%d",&n,&c1,&c2); if(n==0) return 0; printf("%d\n",schimb(n,c1,c2)); } }