def f(m,dx,dy,h,w) i=0 arr=Array.new(h+2).map{Array.new(w+2,0)} c=0 m.each{|e| j=0 e.chars{|e2| if e2=="#" arr[i][j]=1 c+=1 else arr[i][j]=0 end j+=1 } i+=1 } return false if c==0 h.times{|y| w.times{|x| y1=y+dy x1=x+dx if arr[y][x]==1 return false if x1<0 || x1>=w || y1<0 || y1>=h arr[y1][x1]-=1 c-=2 end next if x1<0 || x1>=w || y1<0 || y1>=h return false if arr[y1][x1]<0 } } return c==0 end h,w=gets.split.map{|e| e.to_i} m=[] h.times{ m<<gets.chomp } ok=false h.times{|dy| w.times{|dx| if dy+dx!=0 ok=ok||f(m,dx,dy,h,w) ok=ok||f(m,-dx,dy,h,w) end } } if ok==true puts "YES" else puts "NO" end