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 == '.' }
  ret_x = counter(fld, $h, $w)
  fld = fld.transpose
  ret_y = counter(fld, $w, $h)
  return false if ret_x.size == 0 && ret_y.size == 0
  ret_x.each do |y, x, len|
    len.times{ |i| fld[x + i][y] = nil }
  end
  ret_y.each do |y, x, len|
    len.times{ |i| fld[y][x + i] = nil }
  end
  search(adjust(fld))
end

def counter(fld, r, c)
  ret = []
  r.times do |y|
    cnt = 0
    cur = ''
    s = 0
    c.times do |x|
      next if fld[y][x] == '.'
      if cur == fld[y][x] then cnt += 1
      else
        ret << [y, s, x - s] if cnt >= $n
        cnt = 1
        cur = fld[y][x]
        s = x
      end
    end
    ret << [y, s, c - s] if cnt >= $n
  end
  ret
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'