#include using namespace std; #define BSIZE 65536 int p,t,i,c1,c2; char str[BSIZE]; char buffer[BSIZE]; int readInt() { int number=0,sgn=1; while (!('0'<=buffer[p] && buffer[p]<='9')) { if (buffer[p]=='-') sgn=-1; if (p==BSIZE-1) { fread(buffer,1,BSIZE,stdin); p=0; } else ++p; } while ('0'<=buffer[p] && buffer[p]<='9') { number=number*10+buffer[p]-'0'; if (p==BSIZE-1) { fread(buffer,1,BSIZE,stdin); p=0; } else ++p; } return sgn*number; } int main() { #ifndef ONLINE_JUDGE freopen("a.in","r",stdin); freopen("a.out","w",stdout); #endif fread(buffer,1,BSIZE,stdin); t=0; while (true) { str[0]=0; while ('0'<=buffer[t] && buffer[t]<='9') { str[++str[0]]=buffer[t]; ++t; } if (str[0]==0) return 0; ++t; if (buffer[t]=='\r') return 0; c1=0; while ('0'<=buffer[t] && buffer[t]<='9') { c1=c1*10+buffer[t]-'0'; ++t; } ++t; if (buffer[t]=='\r') return 0; c2=0; while ('0'<=buffer[t] && buffer[t]<='9') { c2=c2*10+buffer[t]-'0'; ++t; } ++t; if (buffer[t]=='\r') return 0; for (i=1;i<=str[0];++i) if (str[i]-'0'==c1) str[i]=c2+'0'; i=1; while (str[i]=='0') ++i; if (i>str[0]) continue; for (;i<=str[0];++i) printf("%c",str[i]); printf("\n"); } return 0; }