import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from math import gcd import itertools H,W = map(int,readline().split()) data = ''.join(read().decode().split()) def test(a,b): if abs(gcd(a,b)) > 1: return False # ax + by = const 上をまとめる words = [[] for _ in range(5000)] for x,y in itertools.product(range(H), range(W)): key = a * x + b * y words[key].append(data[W*x+y]) for w in words: if ''.join(w).replace('##','').find('#') != -1: return False return True answer = 'YES' if any(test(a,b) for a in range(51) for b in range(-51,51)) else 'NO' print(answer)