def solve(block)
  clear(delete(Marshal.load(Marshal.dump(block))))
end

def delete(block)
  h = block.size
  w = block.first.size
  delete = Array.new(h) {Array.new(w)}
  for i in 0...h do
    for j in 2...w do
      if(block[i][j] == block[i][j-1] && block[i][j] == block[i][j-2])
        delete[i][j] = delete[i][j-1] = delete[i][j-2] = true
      end
    end
  end
  for j in 0...w do
    for i in 2...h do
      if(block[i][j] == block[i-1][j] && block[i][j] == block[i-2][j])
        delete[i][j] = delete[i-1][j] = delete[i-2][j] = true
      end
    end
  end
  for i in 0...h do
    for j in 0...w do
      block[i][j] = "." if(delete[i][j])
    end
  end
  block
end

def clear(block)
  h = block.size
  w = block.first.size
  ok = true
  for i in 0...h do
    for j in 0...w do
      ok = false if block[i][j] != "."
    end
  end
  ok
end

h, w, n = gets.split.map(&:to_i)
block = []
h.times do
  block.push(gets.chomp)
end
ok = false
for i in 0...h do
  for j in 1...w do
    next if block[i][j-1] == block[i][j]
    block[i][j-1], block[i][j] = block[i][j], block[i][j-1]
    ok = true if solve(Marshal.load(Marshal.dump(block)))
    block[i][j-1], block[i][j] = block[i][j], block[i][j-1]
  end
end
puts ok ? "YES" : "NO"