h,w=gets.split.map(&:to_i) s = $<.map(&:chomp) flag = false h.times{|i| if flag break end cnt = s[i].count(?*) if cnt == 1 if s[i].index(?*) != 0 s[i][0] = ?* else s[i][1] = ?* end flag = true elsif cnt == 2 if i != 0 s[0][0] = ?* else s[1][0] = ?* end flag = true end } h.times{|i| puts s[i] }