import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random; import std.string, std.conv, std.stdio, std.typecons; struct point { int x; int y; point opBinary(string op)(point rhs) { static if (op == "+") return point(x + rhs.x, y + rhs.y); else static if (op == "-") return point(x - rhs.x, y - rhs.y); } } void main() { auto rd = readln.split.map!(to!int); auto h = rd[0], w = rd[1]; auto aij = iota(h).map!(_ => readln.chomp.map!(c => c == '#').array).array; writeln(calc(h, w, aij) ? "YES" : "NO"); } bool calc(int h, int w, bool[][] aij) { bool valid(point p) { return p.x >= 0 && p.x < w && p.y >= 0 && p.y < h; } point[] pi; foreach (i; 0..h) foreach (j; 0..w) if (aij[i][j]) pi ~= point(j, i); if (pi.empty) return false; auto bp = pi.front; auto di = pi[1..$].map!(p => p - bp); return di.any!((d) { auto visited = new bool[][](h, w); return pi.all!((p) { if (visited[p.y][p.x]) { return true; } else { auto q = p + d; if (!valid(q) || !aij[q.y][q.x] || visited[q.y][q.x]) { return false; } else { visited[p.y][p.x] = true; visited[q.y][q.x] = true; return true; } } }); }); }