#include int main() { int x, y, z, x1, y1, z1, rez[1024]; int i; for (i = 0; i<=1023;++i) rez[i] = 0; x = y = z = x1 = z1 = y1 =1; while (x1 != 0 || y1 != 0 || z1 != 0) { scanf("%d %d %d", &x, &y, &z); x1 = x; y1 = y; z1 = z; int n =1, i =1; while (x) { rez[n] = x % 10; x = x / 10; n++; } for (i = 1;i <= n;++i) if (rez[i] == y) rez[i] = z; int ok = 0; for (i = n; i>=1; --i) { if (rez[i] == 0) { if (ok != 0) printf("%d", rez[i]); } else { ok = 1; printf("%d", rez[i]); } } if (ok == 0 && (x1!= 0 || y1 != 0 || z1 !=0)) printf("0"); if (x1 != 0 || y1 != 0 || z1 != 0) printf("\n"); } return (0); }