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
        
        

buffer = ''
while True:
    line = raw_input()
    if not line: break
    row = line.split(" ")
    if (int(row[0])==0 and int(row[1])==0 and int(row[2])==0):
        break
    if int(row[0]) == 0:
        print int(row[2])
    else:
        print replaceFc(int(row[0]), int(row[1]), int(row[2]))