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