#include <iostream>
#include <string>
#include "Header200.h"
#include <math.h>
#include <algorithm>
#include <set>
using namespace std;
void GridRepainting2() {


	string board[50];

	int h = 0;
	int w = 0;

	bool can = true;

	cin >> h >> w;


	//文字列を入力
	for (int i = 0; i < h; i++) {
		cin >> board[i];

	}


	//'#'の文字列を見つけた場合、上下左右の位置に'#'があるかどうか判定し、ある場合はYESを設定

	//上下左右参照用
	int dx[4] = { 1, -1, 0, 0 };
	int dy[4] = { 0, 0, 1, -1 };

	int num = 0;

	bool flag = true;

	for (int i = 0; i < h; i++) {

		if (can == false) break;

		for (int j = 0; j < w; j++) {



			if (board[i][j] == '#') {

				//上下左右を調べ、一つもない場合は目標達成不可
				num = 0;
				for (int k = 0; k < 4; k++) {

					int ni = i + dy[k];
					int nj = j + dx[k];

					if (ni < 0 || ni >= h) continue;
					if (nj < 0 || nj >= w) continue;
					if (board[ni][nj] == '#') num++;


				}
				if (num == 0) {

					can = false;
					break;
				}
				else {

					can = true;
				}

			}


		}

	}

	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;




}