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 == '.' }
  nfld = fld.map{ |f| f.dup }
  count(fld, $w) do |ret|
    ret.each do |y, x|
      $n.times{ |i| nfld[y][x + i] = nil }
    end
  end
  count(fld.transpose, $h) do |ret|
    ret.each do |y, x|
      $n.times{ |i| nfld[x + i][y] = nil }
    end
  end
  return false unless nfld.flatten.any?{ |v| v.nil? }
  search(adjust(nfld))
end
 
def count(fld, r)
  ret = []
  r.times do |y|
    fld[y].each_cons($n).with_index do |ar, x|
      next if ar[0] == '.'
      ret << [y, x] if ar.all?{|v| v == ar[0] }
    end
  end
  yield(ret)
end
 
def adjust(fld)
  $w.times do |x|
    fld[x].map! { |v| v if /[A-Z]/ =~ v }.compact!
    ($h - fld[x].size).times{ fld[x].unshift('.') }
  end
  fld
end
 
$h, $w, $n = gets.split.map(&:to_i)
fld = $h.times.map{ gets.chomp.split('') }
puts solve(fld) ? 'YES' : 'NO'