#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <cstring>
#include <string>
#include <ctime>
#include <cassert>
#include <utility>

using namespace std;

int main() {
//	freopen("date.in", "r", stdin);
//	freopen("date.out","w", stdout);

	int n, c1, c2;
	cin >> n >> c1 >> c2;
	while(!(n == 0 && c1 == 0 && c2 == 0)) {
	    string s = "";
	    if(n == 0 && c1 == 0) {
            cout << c2 << "\n";
	    } else {
            //int nn = 0;
            while(n >= 1) {
                int c = n % 10;
                n /= 10;
                if(c == c1) {
                    //nn = nn * 10 + c2;
                    s += c2 + '0';
                } else {
                    //nn = nn * 10 + c;
                    s += c + '0';
                }
            }
            int res = 0, i = s.size() - 1;
            while(i >= 0) {
                int c = s[i] - '0';
                res = res * 10 + c;
                i--;
            }
            //reverse(s.begin(), s.end());
            cout << res << "\n";
	    }
        cin >> n >> c1 >> c2;
	}

	return 0;
}