h,w = gets.split.map(&:to_i) sky = [] starflg = true while cin=gets if starflg && cin=~/(-*)\*.*\*/ starflg = nil elsif starflg && cin=~/(-*)\*/ x = $1.size if x == w-1 cin[x-1] = '*' else cin[x+1] = '*' end starflg = false end sky << cin end if starflg == nil f = true sky.each{|s| if f && !(s=~/\*/) puts "*"+"-"*(w-1) f = false else puts s end } else puts sky end