#include<iostream>
using namespace std;
int main()
{
	int n,c1,c2,d,r,z,bol=1;
	do
	{std::cin>>n>>c1>>c2;
			z=1;
			r=0;
			
		if(n==0)
			bol=0;
		else
			while(n)
			{d=0;
			d=n%10;
			n/=10;
			
			if(d==c1)
				r+=c2*z;
			else
				r+=d*z;
				z*=10;}
			
			
			std::cout<<r<<"\n";}
	while(bol==1);
	}