h,w = gets.split.map(&:to_i) ss = [] f=[] for i in 0...h line = gets.chomp f<<[] for j in 0...w f[i] << false if line[j] == '*' ss << [i,j] f[i][j] = true end end end def star(a, b, c) dx1 = a[0] - b[0] dy1 = a[1] - b[1] dx2 = a[0] - c[0] dy2 = a[1] - c[1] dx1 * dy2 != dy1 * dx2 end for i in 0...h for j in 0...w if star([i, j], ss[0], ss[1]) f[i][j] = true for i in 0...h puts (0...w).map{|j| f[i][j] ? '*' : '-'}.join('') end exit 0 end end end p stars