H,W=map(int,input().split())
S=[input() for _ in range(H)]

arr=[]
for h in range(0,H):
    for w in range(0,W):
        if S[w][h]=='#':
            cnt=0
            if w!=0:
                cnt+=S[w-1][h]=='#'
            if w!=W-1:
                cnt+=S[w+1][h]=='#'
            if h!=0:
                cnt+=S[w][h-1]=='#'
            if h!=H-1:
                cnt+=S[w][h+1]=='#'
            arr.append(cnt>0)
print(all(arr))