#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int h, w, n;

bool check(vector<string> g, int a, int b, int c, int d) {
    swap(g[a][b], g[c][d]);
            // fall
        for (int i = h-2; i >= 0; i--) {
            for (int j = 0; j < w; j++) {
                if (g[i][j] != '.' && g[i+1][j] == '.') {
                    int t = i+1;
                    while (t+1 < h && g[t+1][j] == '.') t++;
                    swap( g[i][j], g[t][j]);
                }
            }
        }
    
    //printf("swap g[%d][%d], g[%d][%d]\n",a,b,c,d);
    //for (int i = 0; i < h; i++) {for (int j = 0; j < w; j++) {cout << g[i][j] << " ";}cout << endl;}
    while (1) {
        //cout << "-----------------" << endl;
        bool f = false;
        
        // find w
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (g[i][j] == '.') continue;
                for (int k = 0; 'A'+k <= 'Z'; k++) {
                    if (g[i][j] == 'A'+k || g[i][j] == 'a'+k) {
                        int cnt = 1;
                        int l = j;
                        while (j+1 < w && (g[i][j+1] == 'A'+k || g[i][j+1] == 'a'+k)) {
                            j++;
                            cnt++;
                        }
                        if (cnt >= n) {
                            f = true;
                            for (int m = l; m < l+cnt; m++) g[i][m] = 'a'+k;
                        }
                    }
                }
            }
        }
        // find h
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                for (int k = 0; 'A'+k <= 'Z'; k++) {
                    if (g[j][i] == 'A'+k || g[j][i] == 'a'+k) {
                        int cnt = 1;
                        int l = j;
                        while (j+1 < h && (g[j+1][i] == 'A'+k || g[j+1][i] == 'a'+k)) {
                            j++;
                            cnt++;
                        }
                        if (cnt >= n) {
                            f = true;
                            for (int m = l; m < l+cnt; m++) g[m][i] = 'a'+k;
                        }
                    }
                }
            }
        }
        
        // replace .
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) if (g[i][j] >= 'a' && g[i][j] <= 'z') g[i][j] = '.';
        }
        
        // fall
        for (int i = h-2; i >= 0; i--) {
            for (int j = 0; j < w; j++) {
                if (g[i][j] != '.' && g[i+1][j] == '.') {
                    int t = i+1;
                    while (t+1 < h && g[t+1][j] == '.') t++;
                    swap( g[i][j], g[t][j]);
                }
            }
        }
        //for (int i = 0; i < h; i++) {for (int j = 0; j < w; j++) {cout << g[i][j] << " ";}cout << endl;}
        if (!f) break;
    }
    // check
    bool f = true;
    for (int i = 0; i < h; i++) { 
        for (int j = 0; j < w; j++) {
            if (g[i][j] >= 'A' && g[i][j] <= 'Z') f = false;
        }
    }
    
    if (f) return true;
    else return false;
}

int main(void){
    cin >> h >> w >> n;
    vector<string> g(h);
    for (int i = 0; i < h; i++) cin >> g[i];

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j+1 < w && check(g,i,j,i,j+1)) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3176