#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 ; } cout << s1 << '\n' ; } return 0 ; }