Problem: A rabbit who came to the fair found that the prize for a game at a store was a carrot cake. The rules for this game are as follows.

There is a grid-like field of vertical h squares x horizontal w squares, and each block has at most one block. Each block is a color represented by one of the uppercase letters ('A'-'Z'). When n or more blocks of the same color are lined up in a straight line vertically or horizontally, those blocks disappear.

Participants can select two adjacent cells next to each other and switch their states to each other. When blocks are exchanged, disappeared, or dropped and there are no blocks in the cell below the cell with the block, this block At this time, it disappears when n or more blocks of the same color are lined up again. However, the disappearance of the blocks does not occur while the falling blocks exist, and occurs at the same time when all the blocks have finished falling.

If you eliminate all the blocks on the field with one operation, this game will be successful and you will get a free gift cake. Rabbit wants to get the cake with one entry fee, can not do it If you don't want to participate. From the state of the field at the beginning of the game, answer if the rabbit should participate in this game.



Input

The first line of input is given h, w, n separated by spaces.

2 ≤ h, w, n ≤ 30

In the following h lines, the state of the field is given in order from the top. Uppercase letters represent blocks, and'.' Represents an empty space. The state of the given field is n or more consecutive blocks of the same color in the vertical or horizontal direction. No, no blocks are in a falling state. There is one or more blocks.

Output

Output "YES" if the rabbit should participate in this game, otherwise output "NO" on one line.

Examples

Input

4 6 3
......
...Y..
...Y..
RRYRYY


Output

YES


Input

4 6 3
......
...Y..
...Y..
RRYRY.


Output

NO

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	private static char[][] field, clone;

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int height = scanner.nextInt();
		int width = scanner.nextInt();
		int n = scanner.nextInt();

		field = new char[height][width];// フィールド状態
		for (int i = 0; i < field.length; i++) {
			String line = scanner.next();
			for (int j = 0; j < field[i].length; j++) {
				field[i][j] = line.charAt(j);
			}
		}
		scanner.close();

		clone = new char[height][width];// フィールド状態
		for (int i = 0; i < field.length; i++) {
			for (int j = 0; j < clone[i].length; j++) {
				if (j + 1 < field[i].length) {
					copy();
					exchange(i, j, i, j + 1);
					int rest = height * width;
					while (true) {
						fall();
						vanish(n);
						int check = check();
						if (check == 0) {
							System.out.println("YES");
							return;
						} else if (check == rest) {
							break;
						} else {
							rest = check;
						}
					}
				}
			}
		}

		System.out.println("NO");
		return;

	}

	static void copy() {
		for (int i = 0; i < field.length; i++) {
			for (int j = 0; j < field[i].length; j++) {
				clone[i][j] = field[i][j];
			}
		}
	}

	static boolean vanish(int n) {
		// 消えるところをリストアップ
		ArrayList<Integer[]> list = new ArrayList<Integer[]>();

		// まずは横のつながり
		for (int i = 0; i < clone.length; i++) {
			int start = -1;
			for (int j = 1; j <= clone[i].length; j++) {
				if (clone[i][j - 1] == '.') {
					continue;
				}
				if (start == -1) {
					if (j < clone[i].length && clone[i][j] == clone[i][j - 1]) {
						start = j - 1;
					}
				} else if (j == clone[i].length
						|| clone[i][j] != clone[i][j - 1]) {
					if (j - start >= n) {
						for (int j2 = start; j2 < j; j2++) {
							Integer[] push = { i, j2 };
							list.add(push);
						}
					}
					start = -1;
				}

			}
		}

		// 縦のつながり
		for (int col = 0; col < clone[0].length; col++) {
			int start = -1;
			for (int row = 1; row <= clone.length; row++) {
				if (start == -1) {
					if (row < clone.length
							&& clone[row][col] == clone[row - 1][col]) {
						start = row - 1;
					}
				} else if (row == clone.length
						|| clone[row][col] != clone[row - 1][col]) {
					if (row - start >= n) {
						for (int i = start; i < row; i++) {
							Integer[] push = { i, col };
							list.add(push);
						}
					}
					start = -1;
				}

			}

		}

		for (Integer[] integers : list) {
			int i = integers[0];
			int j = integers[1];
			clone[i][j] = '.';
		}

		return list.size() > 0;

	}

	static void fall() {
		for (int col = 0; col < clone[0].length; col++) {
			Deque<Character> deque = new ArrayDeque<Character>();
			for (int i = clone.length - 1; i >= 0; i--) {
				if (clone[i][col] != '.') {
					deque.add(clone[i][col]);
				}
			}
			for (int i = clone.length - 1; i >= 0; i--) {
				if (!deque.isEmpty()) {
					clone[i][col] = deque.pollFirst();
				} else {
					clone[i][col] = '.';
				}
			}
		}
	}

	static void exchange(int p, int q, int r, int s) {
		char tmp = clone[p][q];
		clone[p][q] = clone[r][s];
		clone[r][s] = tmp;
	}

	static int check() {
		int rest = 0;
		// 残りブロックの数を返す
		for (int i = 0; i < clone.length; i++) {
			for (int j = 0; j < clone[i].length; j++) {
				if (clone[i][j] != '.') {
					rest++;
				}
			}
		}
		return rest;
	}

}