until (arr = gets.chomp) == '0 0 0' n, c1, c2 = arr.split(' ') puts n.gsub(c1, c2).to_i end