#include<bits/stdc++.h>
using namespace std;

bool game(int n, int a, int b, vector<vector<int> > ennichi){

    int h = ennichi.size();
    int w = ennichi[0].size();
    int temp = ennichi[a][b];
    ennichi[a][b] = ennichi[a][b + 1];
    ennichi[a][b + 1] = temp;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(ennichi[i][j] == 0){
                for(int k = i - 1; k >= 0; k--){
                    ennichi[k + 1][j] = ennichi[k][j];
                }
                ennichi[0][j] = 0;
            }
        }
    }

    int r, l, u, d;
    while(1){

        set<pair<int, int> > S;
        

    

        bool end = true;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(ennichi[i][j]){
                    int num = ennichi[i][j];
                    r = j, l = j, u = i, d = i;
                    for(int k = i + 1; k < h; k++){
                        if(ennichi[k][j] != num) break;
                        u = k;
                    }
                    for(int k = i - 1; k >= 0; k--){
                        if(ennichi[k][j] != num) break;
                        d = k;
                    }
                    for(int k = j + 1; k < w; k++){
                        if(ennichi[i][k] != num) break;
                        r = k;
                    }
                    for(int k = j - 1; k >= 0; k--){
                        if(ennichi[i][k] != num) break;
                        l = k;
                    }

                    //if(a == 2 && b == 1 && i == 2 && j == 1) cout << u << " " << d << " " << r << " " << l << endl;
                    if(u - d + 1 >= n || r - l + 1 >= n){                      
                        S.insert({i, j});
                        end = false;
                    }
                }
            }
        }

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(S.find({i, j}) != S.end()) ennichi[i][j] = 0;
            }
        }


        

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(ennichi[i][j] == 0){
                    for(int k = i - 1; k >= 0; k--){
                        ennichi[k + 1][j] = ennichi[k][j];
                    }
                    ennichi[0][j] = 0;
                }
            }
        }

        if(end) break;
    }

    bool flag = true;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            //if(a == 2 && b == 1) cout << ennichi[i][j] << " ";
            if(ennichi[i][j]){
                //if(a == 2 && b == 1) cout << ennichi[i][j] << " ";
                flag = false;
                //break;
            }
        }
        //if(a == 2 && b == 1) cout << endl;
    }

    return flag;
}

int main(){
    int h, w, n; cin >> h >> w >> n;
    vector<vector<int> > ennichi(h, vector<int> (w, 0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char input; cin >> input;
            if(input != '.') ennichi[i][j] = (int)input - 'A' + 1;
        }
    }

    bool flag = false;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w - 1; j++){
            if(ennichi[i][j] || ennichi[i][j + 1]) flag = game(n, i, j, ennichi);
            if(flag){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
}


Measured memory_bytes: 3144