#include using namespace std; int c1, c2; string S; int main() { // freopen("date.in", "r", stdin); // freopen("date.out","w", stdout); cin.sync_with_stdio(false); while (cin >> S >> c1 >> c2) { if (c1 == 0 && c2 == 0 && S == string("0")) { break; } for (size_t i = 0; i < S.size(); i++) { if (S[i] - '0' == c1) { S[i] = '0' + c2; } } while (S.size() > 1 && S[0] == '0') { S = S.substr(1); } cout << S << '\n'; } return 0; }