#include <iostream>
using namespace std;
int c1, c2;
string n;
bool gasit;

int main()
{
	while(1)
	{
		cin >> n >> c1 >> c2;
		if(n.size() == 1 && n[0] == '0' && c1 == 0 && c2 == 0)
			break;
		gasit = false;
		for(int i = 0; i < n.size(); ++i)
		{
			if(i + 1 == n.size())
				gasit = true;
			if(n[i] == c1 + '0')
			{
				if(gasit || c2 != 0)
					cout << c2;
				if(c2 != 0)
					gasit = true;
			}
			else
			{
				if(n[i] != '0')
					gasit = true;
				cout << n[i];
			}
		}
		cout << "\n";
	}
	return 0;
}