class MAP: __slots__ = ['li', 'len_li', 'b', 'ma', 'cnt'] def __init__(self, li): self.li = li self.len_li = len(li) self.b = [1] + [0] * (self.len_li - 1) self.ma = {a:i for i, a in enumerate(li)} self.cnt = 0 def reset(self): self.b = [1] + [0] * (self.len_li - 1) self.cnt = 0 def popleft(self): for i in range(self.cnt, self.len_li): if self.b[i] == 0: self.b[i] = 1 for j in range(i + 1, self.len_li): if self.b[j] == 0: self.cnt = j break return self.li[i] return (-100, -100) def find(self, a): if a not in self.ma: return False self.b[self.ma[a]] = 1 return True def f(m, y, x, len_m): for _ in range(len_m): a = m.popleft() ny = y + a[0] nx = x + a[1] if not m.find((ny, nx)): return False return True def solve(): h, w = map(int, input().split()) s = tuple(input() for _ in range(h)) c_cnt = sum(a.count('#') for a in s) if c_cnt == 0 or c_cnt & 1: return "NO" m = tuple((i, j) for i in range(h) for j in range(w) if s[i][j] == '#') dp = MAP(m) a = dp.li[0] c_cnt = (c_cnt - 2) // 2 for i in range(1, len(m)): y = m[i][0] - a[0] x = m[i][1] - a[1] dp.b[i] = 1 if f(dp, y, x, c_cnt): return "YES" dp.reset() return "NO" print(solve())