#include #define pii pair #define pb emplace_back #define mp make_pair #define ll long long #define oo 1<<18; using namespace std; int n,c1,c2,sol,cif,e; int main() { while(cin>>n>>c1>>c2) { sol=0; e=1; if(!n&&!c1&&!c2) return 0; while(n) { cif=n%10;n/=10; if(cif==c1) cif=c2; sol=cif*e+sol; e*=10; } cout<