class LIST: __slots__ = ['li', 'len_li', 'b', 'ma', 'left'] def __init__(self, li): self.li = li self.len_li = len(li) self.b = [0] * self.len_li self.ma = {a:i for i, a in enumerate(li)} self.left = 0 def __len__(self): return self.b.count(0) def reset(self): self.b = [0] * self.len_li self.left = 0 def pop(self, a): self.b[a] = 1 return self.li[a] def popleft(self): for i in range(self.left, 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.left = j break return self.li[i] return complex(-100, -100) def find(self, a): if a in self.ma and self.b[self.ma[a]] == 0: return True return False def remove(self, a): if self.find(a): self.b[self.ma[a]] = 1 return True return False def f(m, yx, n): for _ in range(n): if not m.remove(m.popleft() + yx): 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(complex(i, j) for i in range(h) for j in range(w) if s[i][j] == '#') a = m[0] dp = LIST(m[1:]) n = len(dp) // 2 for i in range(len(dp)): dp.b[i] = 1 if f(dp, m[i + 1] - a, n): return "YES" dp.reset() return "NO" print(solve())