h, w = gets.split.map(&:to_i) s = [] h.times do s << gets.chomp end ans = [] (0..h - 1).each do |i| tmp = "" j = 0 while j < w if s[i][j] == "." then tmp << "." j += 1 else if s[i][j] == "y" then tmp << "yiwiY9" else tmp << "9Yiwiy" end j += 6 end end ans << tmp end (0..h - 1).each do |i| puts ans[i] end