import strutils, sequtils, algorithm, math proc solve(): string = var hw = readLine(stdin).split(' ').map(parseInt) board = newSeq[string](hw[0]) tBoard = newSeq[string](hw[0]) count = 0 tmpCount: int flag = false for i in countup(0, hw[0] - 1): board[i] = readLine(stdin) count += board[i].count('#') if count mod 2 == 1: return "NO" for hMove in countup(0, hw[0] - 1): for wMove in countup(-hw[1] + 1, hw[1] - 1): tmpCount = 0 flag = false for h in countup(0, hw[0] - 1): tBoard[h] = board[h] for h in countup(0, hw[0] - 1): if hMove + h >= hw[0]: break for w in countup(0, hw[1] - 1): if wMove + w >= hw[1] or wMove + w < 0: break if tBoard[h][w] == '#': if tBoard[hMove + h][wMove + w] == '#': tmpCount += 1 tBoard[h][w] = 'R' tBoard[hMove + h][wMove + w] = 'B' else: flag = true break # else: # flag = true # break if flag: break if tmpCount == count div 2 and not flag: return "YES" return "NO" echo(solve())