#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <cmath>
#include <map>
#include <fstream>
#include <sstream>
#include <set>
#include <iomanip>
#include <deque>
#include <cstring>

#define pb push_back
#define ll long long
#define FOR(I,A,B) for(int I=(A); I <= (B); I++)

using namespace std;

int solve(int c1, int c2, int n) {
	int d = 0;
	int b = 1;

	if(n == 0 && c1 == 0) {
		d = c2;
	}
	while(n) {
		int c = (n % 10 == c1) ? c2 : n % 10;
		d = c*b + d;
		b *= 10;
		n /= 10;
	}

	return d;
}

int main() {
	int c1, c2, n;

	cin >> n >> c1 >> c2;
	while(c1 > 0 || c2 > 0 || n > 0) {
		cout << solve(c1, c2, n) << "\n";
		cin >> n >> c1 >> c2;
	}

	return 0;
}