using System; using System.Collections.Generic; using System.Linq; namespace Nuriwake_CS { class Program { static void Main(string[] args) { Solver mysol = new Solver(); mysol.Solve(); } } class Solver { public void Solve() { bool ans = B.CanNuriwake(); Console.WriteLine(ans ? "YES" : "NO"); } int H, W; Board B; public Solver() { var hw = ria(); H = hw[0]; W = hw[1]; string[] s = new string[H]; for (int i = 0; i < s.Length; i++) { s[i] = rs(); } B = new Board(H, W, s); } static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa() { return Console.ReadLine().Split(' '); } static int[] ria() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); } static long[] rla() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); } static double[] rda() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); } } class Board { public enum color { Black, White, Red, Blue } int H, W; color[,] BaseBoard; int BlackNum; public Board(int h, int w, string[] s) { H = h; W = w; BlackNum = 0; BaseBoard = new color[H, W]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (s[i][j] == '#') { BaseBoard[i, j] = color.Black; BlackNum++; } else { BaseBoard[i,j] = color.White; } } } } public bool CanNuriwake() { if(BlackNum == 0) { return false; } color[,] curBoard = new color[H, W]; var shifts = Coordinate.MakeParallelShifts(H, W); foreach (Coordinate c in shifts) { curBoard = BaseCopy(); bool ok = true; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (curBoard[i, j] == color.Black) { curBoard[i, j] = color.Red; try { if (curBoard[i + c.X, j + c.Y] == color.Black) { curBoard[i + c.X, j + c.Y] = color.Blue; } else { ok = false; break; } } catch (Exception e) { ok = false; break; } } } if (ok == false) break; } if (ok) return ok; } return false; } color[,] BaseCopy() { color[,] ret = new color[H, W]; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { ret[i, j] = BaseBoard[i, j]; } } return ret; } } struct Coordinate { public int X, Y; Coordinate(int x, int y) { X = x; Y = y; } public static Queue MakeParallelShifts(int H, int W) { Queue q = new Queue(); for (int i = 0, j = 0; j < W; j++) { q.Enqueue(new Coordinate(i, j)); } for (int i = 1; i < H; i++) { for (int j = -W + 1; j < W; j++) { q.Enqueue(new Coordinate(i, j)); } } q.Dequeue(); return q; } } }