package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) h, w, n := nextInt(), nextInt(), rune(2500) m, ws := make([][]rune, h), make([]int, w*2) for i := range m { m[i] = []rune(nextLine()) } for i := range ws[:w] { ws[i], ws[len(ws)-1-i] = i, -i } for i := 0; i < h; i++ { for _, j := range ws { if i == 0 && j == 0 { continue } isP, not := true, false for k, v := range m { for l, v2 := range v { if v2 == '.' || v2 == n { continue } not = true if h <= k+i || 0 > l+j || w <= l+j { isP = false break } if m[k+i][l+j] == '.' { isP = false break } m[k+i][l+j], m[k][l] = n, n } } if isP && not { fmt.Println("YES") return } n++ } } fmt.Println("NO") } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }