#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

void init() {
}

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

void down(vector<string> &S, int H, int W) {
    auto inside = [&](int nh, int nw) {
        return 0 <= nh && nh < H && 0 <= nw && nw < W;
    };
    for (int _ = 0; _ < 35; _++) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (isalpha(S[i][j])) {
                    if (inside(i + 1, j) && S[i + 1][j] == '.') {
                        swap(S[i][j], S[i + 1][j]);
                    }
                }
            }
        }
    }
}

void del(vector<string> &S, int n) {
    const int H = S.size();
    const int W = S[0].length();
    down(S, H ,W);
    auto inside = [&](int nh, int nw) {
        return 0 <= nh && nh < H && 0 <= nw && nw < W;
    };
    vector<vector<bool>> ok(H, vector<bool>(W, false));
    bool f = false;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (isalpha(S[i][j])) {
                const char al = S[i][j];
                for (int d = 0; d < 4; d++) {
                    int ni = i;
                    int nj = j;
                    int cnt = 0;
                    while (inside(ni, nj) && S[ni][nj] == al) {
                        ni += dx[d]; nj += dy[d];
                        cnt++;
                    }
                    if (cnt >= n) {
                        f = true;
                        ni = i, nj = j;
                        for (int i = 0; i < cnt; i++) {
                            ok[ni][nj] = true;
                            ni += dx[d]; nj += dy[d];
                        }
                    }
                }
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (ok[i][j]) {
                S[i][j] = '.';
            }
        }
    }
    down(S, H, W);
    if (f) del(S, n);
    return;
}

void out(vector<string> &S) {
    FORE(e, S) cout<<e<<endl;
    cout<<endl;
}

char strbuf[50];
void solve(int h, int w, int n) {
    vector<string> S(h), ok(h, string(w, '.'));
    for (int i = 0; i < h; i++) {
        scanf("%s", strbuf);
        S[i] = strbuf;
    }
    auto inside = [&](int nh, int nw) {
        return 0 <= nh && nh < h && 0 <= nw && nw < w;
    };
    bool yes = false;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int d : {0, 1}) {
                if (inside(i + dx[d], j + dy[d])) {
                    auto cp = S;
                    swap(cp[i][j], cp[i + dx[d]][j + dy[d]]);
                    del(cp, n);
                    yes |= (cp == ok);
                }
            }
        }
    }
    cout << (yes ? "YES" : "NO") << endl;
    exit(0);
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    init();
    while (cin >> n >> m >> p, n) {
        solve(n, m, p);
    }
}

Measured memory_bytes: 3320