#include <iostream> #include <fstream> #include <algorithm> #include <string> #include <cstring> #include <cmath> #include <vector> #include <utility> #include <string> #define ll long long using namespace std; const int NMAX = 500003; string s; int main(){ #ifndef ONLINE_JUDGE ifstream cin("A.in"); ofstream cout("A.out"); #endif int N,M,i,j,l; char c1,c2; while(cin >> s >> c1 >> c2){ if(s == "0" && c1 == '0' && c2 == '0') break; l = s.length(); for(i=0;i<l;++i) if(s[i] == c1) s[i] = c2; //cout << s << '\n'; int j = 0; while(j<l && s[j] == '0') ++j; if(j>=l) cout << "0\n"; else { for(;j<l;++j) cout << s[j]; cout << '\n'; } } return 0; }