#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int H, W, N;

const int dx[] = {1,0}, dy[] = {0,1};

void fall(vector<vector<char>>& field) {
    REP(y, H) REP(x, W) {
        if ('a' <= field[y][x] && field[y][x] <= 'z') {
            field[y][x] = '.';
        }
    }

    REP(x, W) {
        for (int y = H-1; y >= 0; y--) {
            if (field[y][x] == '.') {
                for (int sy = y-1; sy >= 0; sy--) {
                    if (field[sy][x] != '.') {
                        swap(field[y][x], field[sy][x]);
                        break;
                    }
                }
            }
        }
    }
}

bool disappear(int x, int y, int n, char c, int d, vector<vector<char>>& field) {
    int sx = x + dx[d], sy = y + dy[d];
    if (0 <= sx && sx < W && 0 <= sy && sy < H) {
        if (field[sy][sx] == '.') {
        } else if ('A' <= field[sy][sx] && field[sy][sx] <= 'Z') {
            if (field[sy][sx] == c) {
                field[sy][sx] += 0x20;
                if (disappear(sx, sy, n+1, c, d, field)) {
                    return true;
                } else {
                    field[sy][sx] -= 0x20;
                }
            }
        } else {
            if (field[sy][sx] - 0x20 == c) {
                if (disappear(sx, sy, n+1, c, d, field)) {
                    return true;
                }
            }
        }
    }
    return n >= N;
}

bool flip(int x, int y, vector<vector<char>> field) {
    swap(field[y][x], field[y][x+1]);
    bool redo;
    do {
        redo = false;
        fall(field);
        REP(y, H) REP(x, W) {
            if (field[y][x] != '.') {
                bool seen = ('a' <= field[y][x] && field[y][x] <= 'z');
                if (!seen) field[y][x] += 0x20;
                if (disappear(x, y, 1, field[y][x]-0x20, 0, field) || disappear(x, y, 1, field[y][x]-0x20, 1, field)) {
                    redo = true;
                } else {
                    if (!seen) field[y][x] -= 0x20;
                }
            }
        }
//        REP(y, H) {
//            REP(x, W) {
//                LOG("%c", field[y][x]);
//            }
//            LOG("\n");
//        }
    } while (redo);
    REP(y, H) REP(x, W) {
        if ('A' <= field[y][x] && field[y][x] <= 'Z') {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> H >> W >> N;
    vector<vector<char>> field(H, vector<char>(W));
    REP(y, H) REP(x, W) {
        cin >> field[y][x];
    }

    REP(y, H) {
        REP(x, W-1) {
            if (field[y][x] != field[y][x+1] && flip(x, y, field)) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 3140