jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 黒のコマを表す文字 */
	private static final char BLACK = '#';

	/** 上下左右の座標を表す配列 */
	private static final int[] X = { 0, 1, 0, -1 };
	private static final int[] Y = { 1, 0, -1, 0 };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			boolean[][] s = new boolean[h][w];
			IntStream.range(0, h).forEach(i -> {
				char[] t = scanner.next().toCharArray();
				IntStream.range(0, w).forEach(j -> s[i][j] = (t[j] == BLACK));
			});
			for (int i = 0; i < h; i++) {
				KOMA: for (int j = 0; j < w; j++) {
					if (s[i][j]) {
						for (int k = 0; k < X.length; k++) {
							int newX = i + X[k];
							int newY = j + Y[k];
							if ((newX >= 0) && (newX < h) && (newY >= 0) && (newY < w)) {
								if (s[newX][newY]) {
									continue KOMA;
								}
							}
						}
						System.out.println("No");
						return;
					}
				}
			}
			System.out.println("Yes");
		}
	}
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    for (int i=0; i<h; ++i) cin >> s[i];

    vector<vector<int>> t(h, vector<int>(w, 0));
    const int dx[] = {1, 0, -1, 0};
    const int dy[] = {0, 1, 0, -1};
    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {

            char now = s[i][j];
            if (now == '#') {
                for (int d=0; d<3; ++d) {
                    int nx = i + dx[d];
                    int ny = j + dy[d];
                    if (nx < 0 or nx >= h) continue;
                    if (ny < 0 or ny >= w) continue;
                    if (s[nx][ny] == '#') {
                        ++t[i][j];
                        ++t[nx][ny];
                    }
                }
            }
        }
    }
    
    bool flag = true;
    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            if (s[i][j] == '#') {
                if (t[i][j] == 0) flag = false;
            }
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}
//  [cpp]
#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int h, w;
  while (cin >> h >> w) {
    char g[h][w];
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i][j];
      }
    }
    bool f = true;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (g[i][j] == '#') {
          int di[] = {0, 0, -1, +1};
          int dj[] = {-1, +1, 0, 0};
          int cnt = 0;
          for (int d = 0; d < 4; ++d) {
            int ni = i + di[d];
            int nj = j + dj[d];
            unless (0 <= ni && ni < h) continue;
            unless (0 <= nj && nj < w) continue;
            cnt += g[ni][nj] == '#';
          }
          f = f && cnt;
        }
      }
    }
    cout << (f ? "Yes" : "No") << endl;
  }
  
  return 0;
}
//  [cpp]
//long time no ac
#include <bits/stdc++.h>
using namespace std;

#define 	ll				long long
#define 	vii				vector<int>
#define		rep(i,n) 		for(i=0;i<n;i++)
#define		repe(i,I1,I2) 	for(i=I1;i<I2;i++)
#define		INF  			1e9 + 7
#define		pb  			push_back
#define		mp  			make_pair
#define		endl			'\n'
#define 	mod				1000000007


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k,t,c=0,i,j,m;
	t=1;
	//cin>>t;
	
	while(t--)
	{
		cin>>n>>m;
		string s[n];
		rep(i,n)
		{
			cin>>s[i];
		}
		rep(i,n)
		{
			rep(j,m)
			{
				if(s[i][j]=='#')
				{
					if( (i>0 && s[i-1][j]=='#') || (i<n-1 && s[i+1][j]=='#') || (j>0 && s[i][j-1]=='#') || (j<n-1 && s[i][j+1]=='#'))
					{
						continue;
					}
					c=1;
					break;
				}
			}
		}
		if (c==1)
		{

			cout<<"No";
			/* code */
		}
		else
			cout<<"Yes";
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  rep(i, h) cin >> grid[i];
  rep(i, h) rep(j, w) {
    if (grid[i][j] == '#') {
      vector<vector<bool>> used(h, vector<bool>(w));
      queue<pair<int, int>> que;
      que.push({i, j});
      used[i][j] = true;
      int cnt = 1;
      while (!que.empty()) {
        int x, y;
        tie(x, y) = que.front();
        que.pop();
        rep(k, 4) {
          if (x+dx[k] < 0 || x+dx[k] >= h || y+dy[k] < 0 || y+dy[k] >= w)
            continue;
          if (grid[x+dx[k]][y+dy[k]] == '.' || used[x+dx[k]][y+dy[k]])
            continue;
          used[x+dx[k]][y+dy[k]] = true;
          que.push({x+dx[k], y+dy[k]});
          cnt++;
        }
      }
      if (cnt == 1) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#pragma optimize ("O3")
#pragma target ("sse4")
const int MAXN=35;
const int INF=1e9+17;
const int MOD=1000000021;
using namespace std;

char a[60][60];
int h, w;
bool ok(int i, int j) {return i>=0&&j>=0&&i<h&&j<w;}
void mainp()
{
    cin>>h>>w;
    for(int i=0; i<h; i++)
    {
        string s;
        cin>>s;
        for(int j=0; j<w; j++) a[i][j]=s[j];
    }
    
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
        {
            if(a[i][j]=='.') continue;
            int fl=0;
            if(ok(i-1, j)&&a[i-1][j]=='#') fl=1;
            if(ok(i+1, j)&&a[i+1][j]=='#') fl=1;
            if(ok(i, j-1)&&a[i][j-1]=='#') fl=1;
            if(ok(i, j+1)&&a[i][j+1]=='#') fl=1;
            if(fl==0)
            {
                cout<<"No"<<endl;
                return;
            }
        }
        
    cout<<"Yes"<<endl;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mainp();
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

bool vis[55][55];

string s[55];
int n , m;
int dr[] = {0 ,  - 1,  0 ,  1 };
int dc[] = { 1 ,  0 ,-1 ,  0 }; 
int cnt  = 0;
void dfs(int x , int y)
{
	cnt ++;
	//cout<<x<<" "<<y<<endl;
	vis[x][y] =true;
	for(int i = 0; i < 4; i++)
	{
		int tx = x + dr[i];
		int ty = y + dc[i];
		if(tx < 0 || ty < 0 || tx >= n || ty >= m) continue;
		if(s[tx][ty] =='.' || vis[tx][ty] ) continue;
		dfs(tx , ty);
	}
}

int main()
{
	cin>>n>>m;
	for(int i= 0; i < n; i++)
	{
		cin>>s[i];
	}
	
	
	for(int i  = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(s[i][j] =='#')
			{
				cnt = 0;
				memset(vis , false , sizeof vis);
				dfs(i , j);
				if(cnt <= 1)
				{
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}
//  [c]
#include<stdio.h>
char s[50][50];
int i,j;
int f(int a,int b){
	return s[i][j]==s[a][b];
}
int main(void){
	int h,w,num;
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++){
		scanf("%s",s[i]);
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(s[i][j]=='#'){
				num=f(i-1,j)+f(i+1,j)+f(i,j-1)+f(i,j+1);
				if(!num){
					printf("No");
					return 0;
				}
			}
		}
	}
	printf("Yes");
	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;
ll h,w;

int main(void){
    // char ;
    scanf("%lld%lld",&h,&w);
    // ll [n];
    char s[h][w];
    rep(i,0,h){
        scanf("%s",s[i]);
    }
    // ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    ll d[5]={1,0,-1,0,1};
    ll mk;
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='#'){
                mk=0;
                rep(k,0,4){
                    if(s[i+d[k]][j+d[k+1]] == '#' ){
                        mk=1;
                        break;
                    }
                }
                if(mk==0){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}
//  [c]

#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion



//ABC 096 C - Grid Repainting 2
static char s[52][53];
int main(void) {

	int i,j,h, w;
 
	scanf("%d %d",&h,&w);

	for (i = 1; i <= h; i++)
		scanf("%s", &s[i][1]);

	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			if (s[i][j] == '.') continue;

			if (s[i - 1][j] != '#' &&
				s[i + 1][j] != '#' &&
				s[i][j - 1] != '#' &&
				s[i][j + 1] != '#')
			{
				printf("No\n"); return 0;
			}
		}
	}
	
	printf("Yes\n");
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#define Yes()       printf("Yes\n")
#define No()        printf("No\n")

char s[51][51]={0};

int check(int h, int w){
    if     ( h<0 || w<0 )   return 0;
    else if( s[h][w]=='.' ) return 1;
    else                    return 0;
}

int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=0; i<h; i++){ scanf("%s", s[i]); }
    
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if( s[i][j]=='#'
            &&  check(i-1,j)    //上
            &&  check(i+1,j)    //下
            &&  check(i,j-1)    //左
            &&  check(i,j+1) )  //右
            {
                No();
                return 0;
            }
        }
    }
    Yes();
    return 0;
}
//  [c]
#include"stdio.h"
int main(){
    int H,W,res=1;
    scanf("%d%d",&H,&W);
    char s[51][51];
    for(int i=0;i<H;i++){
        scanf("%s",s[i]);
    }
    for(int i=0;i<H&&res;i++){
        for(int j=0;j<W&&res;j++){
            if(s[i][j]=='#'){
                if(s[i-1][j]=='#'||s[i+1][j]=='#'||s[i][j-1]=='#'||s[i][j+1]=='#'){
                    continue;
                }else{
                    res=0;
                }
            }
        }
    }
    if(res) printf("Yes");
    else printf("No");
    return 0;
}
//  [javascript]
function Main(input){
	input=input.split(/\n/);
	var arr=input.splice(0,1);
	var arr=arr[0].split(/\s/);
	arr.forEach(function(e,i,a){a[i]=Number(a[i]);});
	
	var ans="Yes";
	for(var i=0;i<arr[0];i=(i+1)|0){
		for(var j=0;j<arr[1];j=(j+1)|0){
			if(input[i][j]=="#"){
				if(i==0||input[i-1][j]!=="#"){
				if(i==arr[0]-1||input[i+1][j]!=="#"){
				if(j==0||input[i][j-1]!=="#"){
				if(j==arr[1]-1||input[i][j+1]!=="#"){
					ans="No";
					break;
				}}}}
			}
		}
	}
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function isValid(input, i, j) {
    var dx = [-1, 0, 1, 0];
    var dy = [0, -1, 0, 1];
    var k;
    for (k = 0; k < 4; k++) {
        var xx = i + dx[k];
        var yy = j + dy[k]; 
        if (xx < 0 || yy < 0 || xx >= input.length || yy >= input[i].length) continue;
        if (input[xx][yy] === '#') {
            return true;
        }
    }
    return false;
}

function Main(inp) {
    var input = inp.split('\n').slice(1).map(function(line) {
        return line.split('');
    });
    var i, j;
    for (i = 0; i < input.length; i++) {
        for (j = 0; j < input[i].length; j++) {
            var v = input[i][j];
            if (v !== '#') continue; // # だけ
            if (!isValid(input, i, j)) {
                console.log('No');
                return;
            }
        }
    }
    console.log('Yes');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
function main(input) {
  const args = input.split('\n');
  const size = input.split(' ');
  const h = parseInt(size[0], 10);
  const w = parseInt(size[1], 10);
  const s = [];

  for (let i = 0; i < h; i += 1) {
    s[i] = [];
    let input = args[i];
    for (let j = 0; j < w; j += 1) {
      s[i][j] = input[j];
    }
  }
  s[-1] = [];
  s[h] = [];

  for (let i = 0; i < h; i += 1) {
    for (let j = 0; j < w; j += 1) {
      if (s[i][j] === '#') {
        if (s[i-1][j] !== '#' && s[i+1][j] !== '#' &&
            s[i][j-1] !== '#' && s[i][j+1] !== '#') {
          console.log('No');
          return;
        }
      }
    }
  }
  console.log('Yes');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(s) {
	s = s.split("\n");
  s[0] = s[0].split(" ").map(a => +a);
  const h = s[0][0];
  const w = s[0][1];
  var ans = "Yes";
  for(var i = 1; i <= h; i++)
  for(var j = 0; j < w; j++){
    if(s[i][j] === ".")continue;
    if(i !== 1) if(s[i-1][j] === "#")continue;
    if(i !== h) if(s[i+1][j] === "#")continue;
    if(j !== 0) if(s[i][j-1] === "#")continue;
    if(j !== w - 1) if(s[i][j+1] === "#")continue;
    ans = "No";
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var S []string
var h, w int

func main() {
	sc.Split(bufio.ScanWords)
	h, w = nextInt(), nextInt()
	S = make([]string, h)

	for i := 0; i < h; i++ {
		S[i] = nextStr()
	}

	l := []int{1, 0, -1, 0}
	m := []int{0, 1, 0, -1}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if string(S[i][j]) == "#" {
				for k := 0; k < 4; k++ {
					x := i + l[k]
					y := j + m[k]
					if x >= 0 && x < h && y < w && y >= 0 {
						if string(S[x][y]) == "#" {
							break
						} else {
							if k == 3 {
								fmt.Println("No")
								return
							}
						}
					}
				}
			}
		}
	}

	fmt.Println("Yes")
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

func readLine(r *bufio.Reader) []byte {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := r.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return buf
}

func main() {
	r := bufio.NewReaderSize(os.Stdin, 4096)

	var H, W int

	fmt.Scan(&H)
	fmt.Scan(&W)
	s := make([]string, H)

	for i := 0; i < H; i++ {
		s[i] = string(readLine(r))
	}

	//out(H, W, s)
	ans := "Yes"
L:
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			if s[y][x] == '#' {
				flg := 0
				if x != 0 {
					if s[y][x-1] == '#' {
						flg = 1
					}
				}
				if x != W-1 {
					if s[y][x+1] == '#' {
						flg = 1
					}
				}
				if y != 0 {
					if s[y-1][x] == '#' {
						flg = 1
					}
				}
				if y != H-1 {
					if s[y+1][x] == '#' {
						flg = 1
					}

				}
				if flg == 0 {
					ans = "No"
					break L
				}
			}
		}
	}
	out(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h, w := scanInt(), scanInt()
	ss := make([]string, h)
	for i := 0; i < h; i++ {
		ss[i] = scanString()
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if ss[i][j] == '.' {
				continue
			}
			f := false
			for k := 0; k < 4; k++ {
				if i+dy[k] >= 0 && i+dy[k] < h && j+dx[k] >= 0 && j+dx[k] < w {
					if ss[i+dy[k]][j+dx[k]] == '#' {
						f = true
					}
				}
			}
			if !f {
				fmt.Fprintln(wr, "No")
				return
			}
		}
	}
	fmt.Fprintln(wr, "Yes")
}

var dy, dx = []int{0, -1, 0, 1}, []int{1, 0, -1, 0}
//  [go]
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)

	var tx []int
	var ty []int

	for i := 0; i < h; i++ {
		var s string
		fmt.Scanf("%s", &s)
		for k, v := range s {
			if v == 35 {
				tx = append(tx, i)
				ty = append(ty, k)
			}
		}
	}

	d := [][]int{
		[]int{-1, 0},
		[]int{0, 1},
		[]int{0, -1},
		[]int{1, 0},
	}

	for i := 0; i < len(tx); i++ {
		x, y := tx[i], ty[i]

		cnt := 0
		for _, dd := range d {
			xdash, ydash := x+dd[0], y+dd[1]
			if xdash < 0 || ydash < 0 {
				continue
			}
			for j := 0; j < len(tx); j++ {
				if xdash == tx[j] && ydash == ty[j] {
					cnt = cnt + 1
					break
				}
			}
		}
		if cnt == 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}
//  [go]
package main

import (
        "fmt"
        "strings"
)

func solution(h, w int, s [][]string) string {
        for i := 0; i < h; i++ {
                for j := 0; j < w; j++ {
                        if s[i][j] == "#" {
                                if i > 0 && s[i-1][j] == "#" {
                                        continue
                                }
                                if i < h-1 && s[i+1][j] == "#" {
                                        continue
                                }
                                if j > 0 && s[i][j-1] == "#" {
                                        continue
                                }
                                if j < w-1 && s[i][j+1] == "#" {
                                        continue
                                }
                                return "No"
                        }
                }
        }
        return "Yes"
}

func main() {
        var h, w int
        fmt.Scan(&h, &w)
        s := make([][]string, h)
        for i := range s {
                var t string
                fmt.Scan(&t)
                s[i] = strings.Split(t, "")
        }
        fmt.Println(solution(h, w, s))
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	H, W := ReadInt(), ReadInt()
	grid := make([]string, H)
	for i := 0; i < H; i++ {
		grid[i] = ReadString()
	}

	dirX := []int{-1, 0, 1, 0}
	dirY := []int{0, 1, 0, -1}
	for h := 0; h < H; h++ {
		for w := 0; w < W; w++ {
			if grid[h][w] == '.' {
				continue
			}
			foundBlack := false
			for i := 0; i < 4; i++ {
				nw := w + dirX[i]
				nh := h + dirY[i]
				if nw < 0 || nw >= W || nh < 0 || nh >= H {
					continue
				}
				if grid[nh][nw] == '#' {
					foundBlack = true
					break
				}
			}
			if !foundBlack {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
//  [ruby]
H,W=gets.split.map(&:to_i)
s=$<.read.tr("#.\n",'10').to_i 2
puts [1,-1,W+1,-W-1].inject(0){|r,x|r|=(s << x) & s} == s ? "Yes" : "No"
//  [ruby]
H, W = gets.chomp.split.map(&:to_i)

arr = []
illegals = []

result = true

def search_alone(str)
  len = str.length
  counter = 0
  bads = []
  while counter < len
    if str[counter] === '#'
      if str[counter+1] === '#'
        counter += 2
      elsif str[counter-1] === '#'
        counter += 1
      else
        bads << counter
        counter += 1
      end
    else
      counter += 1
    end
  end
  bads
end

H.times do
  arr << gets.chomp
end

for el in arr
  illegals << search_alone(el)
end

illegals.each_with_index {|el, index|
  el.each do |i|
    targets = [arr[[index-1, 0].max][i], (arr[index+1] || [])[i]]
    unless targets.include?('#')
      result = false
      break
    end
  end
  next if result
}

if result
  puts 'Yes'
else
  puts 'No'
end
//  [ruby]
h, w = gets.split.map(&:to_i)
s = Array.new(h) { gets.chomp.chars }

s.each { |e| e << '.' }
s << '.' * w

1.upto(h) do |i|
  1.upto(w) do |j|
    next if s[i][j] == '.'

    if s[i][j - 1] == '.' && s[i][j + 1] == '.' &&
       s[i - 1][j] == '.' && s[i + 1][j] == '.'
      puts :No
      exit
    end
  end
end

puts :Yes
//  [ruby]
h, w = gets.chomp.split.map(&:to_i)
s = []
h.times do |i|
  s[i] = gets.chomp.split("").map(&:to_s)
end

h.times do |i|
  w.times do |j|
    if s[i][j] != "."
      # 右側に探索
      if j + 1 < w && s[i][j + 1] != "."
        s[i][j] = "@"
        x = 1
        while (j + x < w) do
          break if s[i][j + x] == "."
          if s[i][j + x] != "."
            s[i][j + x] = "@"
            y = 1
            while (i + y < h) do
              break if s[i + y][j + x] == "."
              s[i + y][j + x] = "@" if s[i + y][j + x] != "."
              y += 1
            end
          end
          x += 1
        end
      end
      # 下側に探索
      if i + 1 < h && s[i + 1][j] != "."
        s[i][j] = "@"
        y = 1
        while (i + y < h) do
          break if s[i + y][j] == "."
          s[i + y][j] = "@" if s[i + y][j] != "."
          y += 1
        end
      end
    end
  end
end

result = "Yes"
s.each do |si|
  result = "No" if si.include?("#")
end

puts result
//  [ruby]
#set
h,w = gets.chomp.split(" ").map(&:to_i)
line = Array.new(h)
squares = Array.new(h) {Array.new(w, 0)}
answer = "Yes"

(0 .. h - 1).each do |i|
    line[i] = gets.chomp
    (0 .. w - 1).each do |j|
        squares[i][j] = line[i].split("")[j]
    end
end

#main
(0 .. h - 1).each do |i|
    (0 .. w - 1).each do |j|
        # p squares[i][j]
        if squares[i][j] == "#" then
            chk_flag = 0
            (i - 1 .. i + 1).each do |x|
                (j - 1 .. j + 1).each do |y|
                    if ( x == i || y == j ) && ( x >= 0 && x < h ) && ( y >= 0 && y < w ) then
                        if x == i && y == j then
                            next
                        else
                            if squares[x][y] == "#" then
                                chk_flag += 1
                            end
                        end
                    end
                end
            end
            
            if chk_flag == 0 then
                answer = "No"
                print ("#{answer}\n")
                exit
            end
        end
    end
end

print ("#{answer}\n")
//  [ruby]
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

H, W = get_ints

S = []
H.times do |i|
  S[i] = gets.chomp.split('')
end

def check(i, j, array)
  return true if array[i][j] != '#'

  test = []
  if i > 0
    test << array[i-1][j]
  end
  if i < array.length - 1
    test << array[i+1][j]
  end
  if j > 0
    test << array[i][j-1]
  end
  if j < array[0].length - 1
    test << array[i][j+1]
  end
  test.any? { |s| s == '#' }
end

ans = true
S.each.with_index do |h, i|
  S.each.with_index do |s, j|
    unless check(i, j, S)
      ans = false
      break
    end
  end
  break unless ans
end

puts ans ? 'Yes' : 'No'
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        ss: [String; h],
    }
    let s = ss
        .iter()
        .map(|s| s.chars().collect::<Vec<_>>())
        .collect::<Vec<_>>();
    for y in 0..h {
        for x in 0..w {
            if s[y][x] == '#' {
                if y > 0 {
                    if s[y - 1][x] == '#' {
                        continue;
                    }
                }
                if y < h - 1 {
                    if s[y + 1][x] == '#' {
                        continue;
                    }
                }
                if x > 0 {
                    if s[y][x - 1] == '#' {
                        continue;
                    }
                }
                if x < w - 1 {
                    if s[y][x + 1] == '#' {
                        continue;
                    }
                }
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}
//  [rust]
use std::io::BufRead;
fn main() {
    let f = read_field();
    println!("{}", if solve(&f) { "Yes" } else { "No" })
}

fn solve(f: &Field) -> bool {
    for y in 0..f.h {
        for x in 0..f.w {
            if f.at(x, y).unwrap_or(false) {
                // we need to paint here
                if !&[
                    (x.checked_sub(1), Some(y)),
                    (Some(x + 1), Some(y)),
                    (Some(x), y.checked_sub(1)),
                    (Some(x), Some(y + 1)),
                ]
                .iter()
                .any(|&(nx, ny)| f.at_opt(nx, ny).unwrap_or(false))
                {
                    return false;
                }
            }
        }
    }
    true
}

fn read_field() -> Field {
    let stdin = std::io::stdin();
    let mut input = stdin.lock();
    let mut l = String::new();
    let _ = input.read_line(&mut l);
    let hw: Vec<u32> = l
        .split_whitespace()
        .map(|n| n.parse().expect("readnumerror!"))
        .collect();
    let h = hw[0];
    let w = hw[1];
    let mut f: Vec<Cell> = Vec::with_capacity((h * w) as usize);
    for line in input.lines() {
        for c in line.expect("read line error").trim().chars() {
            match c {
                '.' => f.push(false),
                '#' => f.push(true),
                _ => panic!(format!("unexpected char {}", c)),
            }
        }
    }
    Field {
        h: h,
        w: w,
        field: f,
    }
}

struct Field {
    h: u32,
    w: u32,
    field: Vec<Cell>,
}

impl Field {
    fn at_opt(&self, x: Option<u32>, y: Option<u32>) -> Option<Cell> {
        if x.is_none() || y.is_none() {
            return None;
        }
        let x = x.unwrap();
        let y = y.unwrap();
        if x < self.w && y < self.h {
            self.field
                .get(x as usize + y as usize * (self.w as usize))
                .map(|&b| b)
        } else {
            None
        }
    }
    // fn at_opt(&self, x: Option<u32>, y: Option<u32>) -> Option<Cell> {
    //     if x? < self.w && y? < self.h {
    //         self.field
    //             .get(x? as usize + y? as usize * (self.w as usize))
    //             .copied()
    //     } else {
    //         None
    //     }
    // }
    fn at(&self, x: u32, y: u32) -> Option<Cell> {
        if x < self.w && y < self.h {
            self.field
                .get(x as usize + y as usize * (self.w as usize))
                .map(|&b| b)
        } else {
            None
        }
    }
}

type Cell = bool;
//  [rust]
use std::io;

fn read_grid() -> Vec<Vec<char>> {
    let mut line = String::new();
    let mut inputs = Vec::<Vec<char>>::new();
    io::stdin().read_line(&mut line).unwrap();
    let hw: Vec<i32> = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect();
    line.clear();
    for _ in 0..hw[0] {
        io::stdin().read_line(&mut line).unwrap();
        let line_chars: Vec<char> = line.trim().chars().collect();
        inputs.push(line_chars);
        line.clear();
    }
    inputs
}

fn check_sharp(grid: &Vec<Vec<char>>, x: i32, y: i32) -> bool {
    let max_w = (grid[0].len() - 1) as i32;
    let max_h = (grid.len() - 1) as i32;
    if x > max_w || x < 0 {
        return false;
    }
    if y > max_h || y < 0 {
        return false;
    }

    let neighbor = grid[y as usize][x as usize];
    if neighbor == '#' {
        return true;
    }
    return false;
}

fn solve(grid: Vec<Vec<char>>) -> &'static str {
    let h = grid.len();
    let w = grid[0].len();
    for i in 0..h {
        for j in 0..w {
            if grid[i][j] == '.' {
                continue;
            }
            let x = j as i32;
            let y = i as i32;
            if check_sharp(&grid, x + 1, y)
                || check_sharp(&grid, x - 1, y)
                || check_sharp(&grid, x, y + 1)
                || check_sharp(&grid, x, y - 1)
            {
                continue;
            } else {
                return "No";
            }
        }
    }
    "Yes"
}

fn main() {
    let grid = read_grid();
    let res = solve(grid);
    println!("{}", res);
}
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        h: usize,
        w: usize,
        // s: [Chars;h],
    }

    let mut s: Vec<Vec<char>> = vec![vec!['d';w+5];1];
    for i in 0..h {
        let mut add: Vec<char> = vec!['d';1];
        input!{
            s_tmp: Chars,
        }
        add.extend(s_tmp);
        add.push('d');
        debug!(add);
        s.push(add);
    }
    s.push(vec!['d';w+5]);
    for i in 0..h+2 {
        for j in 0..w+2 {
            if s[i][j]=='#' && s[i-1][j]=='.' && s[i][j-1]=='.' 
            && s[i][j+1]=='.' && s[i+1][j]=='.' {
                println!("No");
                debug!(i);
                debug!(j);
                return;
            }
        }
    }

    println!("Yes");
    
}
//  [rust]
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        grid: [Chars; h],
    }

    let mov = [(1, 0), (0, 1), (-1, 0), (0, -1)];

    for y in 0..h {
        for x in 0..w {
            if grid[y][x] == '.' {
                continue;
            }
            let mut isolate = true;
            for &mo in &mov {
                let next_x = x as isize + mo.0;
                let next_y = y as isize + mo.1;

                if next_x < 0 || next_x >= w as isize || next_y < 0 || next_y >= h as isize {
                    continue;
                }

                let next_x = next_x as usize;
                let next_y = next_y as usize;

                if grid[next_y][next_x] == '#' {
                    isolate = false;
                }
            }
            if isolate {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}
//  [rust]
use proconio::{input, fastout , marker::*};
#[fastout]
fn main() {
  input!{
    h:usize,
    w:usize,
    s:[Chars;h]
  }
  let dx:Vec<i64> = vec![1,-1,0,0];
  let dy:Vec<i64> = vec![0,0,1,-1];
  let mut can : bool = true;
  for i in 0..h {
      for j in 0..w {
          if s[i][j] != '#' {continue;}
          let mut hoge : bool = false;
          for n in 0..4 {
              let x : i64 = j as i64 + dx[n];
              let y : i64 = i as i64 + dy[n];
              if 0 <= x && x < w as i64 && 0 <= y && y < h as i64 {
                if s[y as usize][x as usize] == '#'{
                    hoge = true;
                    break;
                }
              }
          }
          if !hoge {can = false;}
      }
  }
  println!("{}", if can {"Yes"} else {"No"});
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let hw = readInts()
    let (h, w) = (hw[0], hw[1])
    var table = [[String]]()
    for i in 0..<h {
        table.append(readLine()!.map { String($0)} )
    }
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    for i in 1..<h - 2{
        for j in 1..<w - 2{
            
            if table[i][j] == "#" {
                if table[i + 1][j] == "." && table[i - 1][j] == "." && table[i][j + 1] == "." && table[i][j - 1] == "." {
                    print("No")
                    return
                }
            }
            
        }
        
    }
    print("Yes")
}
    main()
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (H, W) = (input[0], input[1])
var board = [[String]]()
for _ in 0..<H {
    board += [readLine()!.toArray()]
}
var ans = "Yes"
loop: for i in 0..<H {
    for j in 0..<W {
        if board[i][j] == "#" {
            if board[max(i-1,0)][j] == "." && board[min(i+1,H-1)][j] == "." && board[i][max(j-1,0)] == "." && board[i][min(j+1,W-1)] == "." {
                ans = "No"
                break loop
            }
        }
    }
}
print(ans)
//  [typescript]
function*stdinIter(){const t=require("fs").readFileSync("/dev/stdin","utf-8").trim().split(/\n|\s/);yield*t}function readMany(t,e){const i=e||this.iter||(this.iter=stdinIter()),n=[];for(let e=0;e<t;e+=1)n.push(i.next().value);return n};

(() => {
    const [ h, w ] = readMany(2)
    const s = []
    for (let i = 0; i < h; i += 1) {
        const tmp = readMany(1)[0].split('')
        s.push(tmp)
    }

    const get = (arr, i, j) => {
        const tmp = arr[i]
        if (tmp) {
            return tmp[j]
        } else {
            void 0
        }
    }

    for (let i = 0; i < h; i += 1) {
        for (let j = 0; j < w; j += 1) {
            if (get(s, i, j) != '#') continue

            if (
                get(s, i - 1, j) == '#' ||
                get(s, i, j - 1) == '#' ||
                get(s, i, j + 1) == '#' ||
                get(s, i + 1, j) == '#'
            ) {
                // ok
            } else {
                return console.log('No')
            }
        }
    }

    console.log('Yes')
})()
//  [typescript]
import * as fs from 'fs'

const getInput = (): string => {
  return (fs.readFileSync('/dev/stdin', 'utf8') as string).trim()
}

export const solveAbc096c = () => {
  const input = getInput()

  const arr = input.trim().split('\n').map(v => v.trim())
  // console.log(arr)

  const numbers = arr[0].trim().split(' ').map(Number)
  const H = numbers[0]
  const W = numbers[1]

  const grid = arr.slice(1).map(v => v.split(''))
  // console.log(grid)

  let extendedGrid = grid.slice()
  const dummy = [...Array(W)].map(_ => '.')
  extendedGrid = [dummy].concat(extendedGrid).concat([dummy])
  extendedGrid = extendedGrid.map(v => ['.'].concat(v).concat('.'))
  // console.log(extendedGrid)

  for (let i = 1; i <= H; i += 1) {
    for (let j = 1; j <= W; j += 1) {
      if (extendedGrid[i][j] === '.') {
        continue
      }

      let count = 0
      if (extendedGrid[i - 1][j] === '#') count += 1
      if (extendedGrid[i][j - 1] === '#') count += 1
      if (extendedGrid[i][j + 1] === '#') count += 1
      if (extendedGrid[i + 1][j] === '#') count += 1
      // console.log(count)
      if (count === 0) {
        console.log('No')
        return
      }
    }
  }

  console.log('Yes')
}

solveAbc096c()
//  [typescript]
{
  const Main = input => {
    input = input.split("\n")
    let [h, w] = input[0].split(" ").map(v => parseInt(v))

    const list = []
    for (let i = 1; i <= h; i++) {
      list.push(input[i].split(''))
    }

    const result = list.every((raw, rawI) => {
      return raw.every((v, i) => {
        return v === '.' ||
          // 無駄多いけど...
          (list[rawI][i - 1] != null && list[rawI][i - 1] === '#') ||
          (list[rawI][i + 1] != null && list[rawI][i + 1] === '#') ||
          (list[rawI - 1] != null && list[rawI - 1][i] === '#') ||
          (list[rawI + 1] != null && list[rawI + 1][i] === '#')
      })
    })
    if (result) {
      console.log('Yes')
    } else {
      console.log('No')
    }
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}
//  [python]
print ' '.join(raw_input().split(','))
//  [python]
s=input()
s=s.replace(',',' ')
print(s)
//  [python]
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
# gcd
from fractions import gcd
# 切り上げ，切り捨て
from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
from collections import Counter
import math
from functools import reduce
# input関係の定義
input = sys.stdin.readline


def ii(): return int(input())


def mi(): return map(int, input().rstrip().split())


def lmi(): return list(map(int, input().rstrip().split()))


def li(): return list(input().rstrip())


# template



def solve(s: list):
    print(*s)


def main():

    # def iterate_tokens():
    #     for line in sys.stdin:
    #         for word in line.split(','):
    #             yield word
    # tokens = iterate_tokens()
    # s = next(tokens)  # type: str
    # solve(s)
    word = list(input().rstrip().split(','))
    solve(word)


if __name__ == '__main__':
    main()
//  [java]
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        System.out.println(s.replaceAll(","," "));
    }
}