#include using namespace std; int repl(int n, int c1, int c2) { if (n == 0) return 0; if (n % 10 == c1) { return repl(n / 10, c1, c2) * 10 + c2; } else return repl(n / 10, c1, c2) * 10 + n % 10; } int main() { int n, c1, c2; while (1) { cin >> n >> c1 >> c2; if (!n && !c1 && !c2) break; cout << repl(n, c1, c2) << '\n'; } return 0; }