#include using namespace std ; string s ; int cif1, cif2 ; int number = 0; int main() { while(cin) { cin >> s >> cif1 >> cif2 ; if(s == "0" && cif1 == 0 && cif2 == 0) return 0 ; for(int i = 0 ; i < s.size() ; ++ i) {if((s[i] - '0') == cif1) s[i] = cif2 + '0' ; } bool ok = false ; int cnt = 0 ; for(int i = 0 ; i < s.size() ; ++ i) if(cnt == 0 && (s[i] - '0') == 0){ cnt = 0 ; continue ; } else {cout << s[i] - '0' ; ok = true ; } if(ok == false) cout << 0 ; cout << '\n' ; } }