def solve(fld)
  $h.times do |y|
    fld[y].each_cons(2).with_index do |(a, b), x|
      if a != b
        fld[y][x], fld[y][x+1] = fld[y][x+1], fld[y][x]
        return true if search(adjust(fld.transpose))
        fld[y][x], fld[y][x+1] = fld[y][x+1], fld[y][x]
      end
    end
  end
  false
end

def search(fld)
  return true if fld.flatten.all?{ |v| v == '.' }
  res_x = counter(fld, $h)
  fld = fld.transpose
  res_y = counter(fld, $w)
  return false if res_x.size == 0 && res_y.size == 0
  res_x.each do |y, x|
    $n.times{ |i| fld[x + i][y] = nil }
  end
  res_y.each do |y, x|
    $n.times{ |i| fld[y][x + i] = nil }
  end
  search(adjust(fld))
end

def counter(fld, r)
  res = []
  r.times do |y|
    fld[y].each_cons($n).with_index do |ar, x|
      next if ar[0] == '.'
      res << [y, x] if ar.all?{|v| v == fld[y][x] }
    end
  end
  res
end

def adjust(fld)
  $w.times do |x|
    fld[x].map! { |v| v if v =~ /[A-Z]/ }.compact!
    ($h - fld[x].size).times{ fld[x].unshift('.') }
  end
  fld.transpose
end

$h, $w, $n = gets.split.map(&:to_i)
fld = $h.times.map{ gets.chomp.split('') }
puts solve(fld) ? 'YES' : 'NO'