#include #include using namespace std; const int NMAX = 100000 + 1; char s[NMAX]; int main() { int l; bool ok; char c1, c2; while(cin >> s) { cin >> c1 >> c2; l = strlen(s); if (l == 1 && s[0] == '0' && c1 == '0' && c2 == '0') break; if (c2 == '0') { int i = 0; while(s[i] == c1) i++; if (i == l) cout << "0\n"; else { for (; i < l; i++) { if (s[i] == c1) s[i] = c2; cout << s[i]; } cout << '\n'; } continue; } for (int i = 0; i < l; i++) { if (s[i] == c1) s[i] = c2; cout << s[i]; } cout << '\n'; } return 0; }