def replaceFc(n, c1, c2): nNew = 0 p = 1 while(n!=0): cAux = n%10 if(cAux == c1): cAux = c2 n = n/10 nNew = p*cAux + nNew p = p * 10 return nNew row = raw_input().split(' ') while not(int(row[0])==0 and int(row[1])==0 and int(row[2])==0): print replaceFc(int(row[0]), int(row[1]), int(row[2])) row = raw_input().split(' ')