def solve(fld)
  $h.times do |y|
    fld[y].each_cons(2).with_index do |(a, b), x|
      if a != b
        nfld = fld.map{ |ar| ar.dup }
        nfld[y][x], nfld[y][x+1] = nfld[y][x+1], nfld[y][x]
        return true if search(adjust(nfld.transpose.map{|ar| ar.reverse} ))
      end
    end
  end
  false
end
  
def search(fld)
  return true if fld.flatten.all?{ |v| !v }
  ret_x = count(fld, $w)
  ret_y = count(fld.transpose, $h)
  return false if ret_x.size == 0 && ret_y.size == 0
  ret_x.each do |y, x|
    $n.times{ |i| fld[y][x + i] = nil }
  end
  ret_y.each do |y, x|
    $n.times{ |i| fld[x + i][y] = nil }
  end
  search(adjust(fld))
end
  
def count(fld, r)
  ret = []
  r.times do |y|
    fld[y].each_cons($n).with_index do |ar, x|
      next unless ar[0]
      ret << [y, x] if ar.all?{|v| v == ar[0] }
    end
  end
  ret
end
  
def adjust(fld)
  $w.times do |x|
    fld[x].map! { |v| v if /[A-Z]/ =~ v }.compact!
  end
  fld.map!{|ar| ar.fill(nil, ar.size...$h) }
end
  
$h, $w, $n = gets.split.map(&:to_i)
fld = $h.times.map{ gets.chomp.split('').map{ |v| v if /[A-Z]/ =~ v } }
puts solve(fld) ? 'YES' : 'NO'