Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.

A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.[Image]

Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.

Please, tell Ciel if she can draw the crosses in the described way.


-----Input-----

The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.

Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.


-----Output-----

Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".


-----Examples-----
Input
5
.#...
####.
.####
...#.
.....

Output
YES

Input
4
####
####
####
####

Output
NO

Input
6
.#....
####..
.####.
.#.##.
######
.#..#.

Output
YES

Input
6
.#..#.
######
.####.
.####.
######
.#..#.

Output
NO

Input
3
...
...
...

Output
YES



-----Note-----

In example 1, you can draw two crosses. The picture below shows what they look like.[Image]

In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.

Difficulty: EASY
Tags: Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
h = int(input())
l = [c == '#' for _ in range(h) for c in input()]
w = len(l) // h
pattern = (0, w - 1, w, w + 1, 2 * w)
for idx in range(1, (h - 2) * w - 1):
	if all((l[_ + idx] for _ in pattern)):
		for _ in pattern:
			l[_ + idx] = False
print(('YES', 'NO')[any(l)])


n = int(input())
a = [list(input()) for i in range(n)]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == a[i - 1][j] == a[i][j + 1] == a[i + 1][j] == a[i][j - 1] == '#':
			a[i][j] = a[i - 1][j] = a[i][j + 1] = a[i + 1][j] = a[i][j - 1] = '.'
print(sum((a[i].count('#') for i in range(n))) == 0 and 'YES' or 'NO')


def verify_cross(i, j, matrix):
	for k in range(3):
		try:
			if matrix[i + k][j] == '0':
				return False
		except:
			return False
	for k in [-1, 0, 1]:
		try:
			if matrix[i + 1][j + k] == '0':
				return False
		except:
			return False
	return True

def main():
	n = int(input())
	matrix = []
	crosses = ''
	for i in range(n):
		st_row = input()
		crosses += st_row
		row = [i for i in st_row]
		matrix.append(row)
	if crosses.count('#') % 5 != 0:
		print('NO')
		return
	for i in range(n):
		for j in range(n):
			if matrix[i][j] == '#':
				if verify_cross(i, j, matrix):
					try:
						matrix[i + 2][j] = '0'
						matrix[i][j] = '0'
						matrix[i + 1][j] = '0'
						matrix[i + 1][j - 1] = '0'
						matrix[i + 1][j + 1] = '0'
					except:
						print('NO')
						return
				else:
					print('NO')
					return
	print('YES')
main()


n = int(input())
ar = [list(input()) for _ in range(n)]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if ar[i][j] == '#' and ar[i - 1][j] == '#' and (ar[i + 1][j] == '#') and (ar[i][j + 1] == '#') and (ar[i][j - 1] == '#'):
			ar[i][j] = ar[i + 1][j] = ar[i - 1][j] = ar[i][j + 1] = ar[i][j - 1] = '.'
flag = True
for i in range(n):
	if ar[i].count('#') > 0:
		flag = False
		break
print('YES' if flag else 'NO')


n = int(input())
b = [list(input()) for _ in range(n)]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if b[i][j] == b[i - 1][j] == b[i + 1][j] == b[i][j - 1] == b[i][j + 1] == '#':
			b[i][j] = b[i - 1][j] = b[i + 1][j] = b[i][j - 1] = b[i][j + 1] = '.'
print('NO' if any((True for r in b if '#' in r)) else 'YES')


n = int(input())
a = []
for i in range(n):
	a.append(list((1 if c == '#' else 0 for c in input())))
for i in range(n):
	for j in range(n):
		if a[i][j]:
			if i + 2 >= n or j + 1 >= n or j == 0:
				print('NO')
				return
			if a[i + 1][j] + a[i + 2][j] + a[i + 1][j - 1] + a[i + 1][j + 1] != 4:
				print('NO')
				return
			a[i][j] = a[i + 1][j] = a[i + 2][j] = a[i + 1][j - 1] = a[i + 1][j + 1] = 0
print('YES')


n = int(input())
a = []
err = 0
for i in range(n):
	a.append(list(input()))
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == '#':
			if a[i + 1][j] == '#' and a[i][j + 1] == '#' and (a[i - 1][j] == '#') and (a[i][j - 1] == '#'):
				a[i + 1][j] = '.'
				a[i][j + 1] = '.'
				a[i - 1][j] = '.'
				a[i][j - 1] = '.'
				a[i][j] = '.'
for i in range(n):
	for j in range(n):
		if a[i][j] == '#':
			err = 1
			break
if err == 1:
	print('NO')
else:
	print('YES')


import sys

def delete_plus(center_column, center_row):
	global area
	try:
		if (area[center_column - 1][center_row] == '#' and area[center_column + 1][center_row] == '#' and (area[center_column][center_row - 1] == '#') and (area[center_column][center_row + 1] == '#') and (area[center_column][center_row] == '#')) is True:
			area[center_column - 1][center_row] = '.'
			area[center_column + 1][center_row] = '.'
			area[center_column][center_row - 1] = '.'
			area[center_column][center_row + 1] = '.'
			area[center_column][center_row] = '.'
		else:
			print('NO')
			sys.exit()
	except IndexError:
		print('NO')
		sys.exit()
length = int(input())
area = [None] * length
for i in range(length):
	area[i] = [j for j in input()]
while True:
	flag = True
	for i in range(length):
		for j in range(length):
			if area[i][j] == '#':
				empty = 0
				side = ''
				if i == 0 or area[i - 1][j] == '.':
					empty += 1
				else:
					side = 'up'
				if i == length - 1 or area[i + 1][j] == '.':
					empty += 1
				else:
					side = 'down'
				if j == 0 or area[i][j - 1] == '.':
					empty += 1
				else:
					side = 'left'
				if j == length - 1 or area[i][j + 1] == '.':
					empty += 1
				else:
					side = 'right'
				if empty == 3:
					if side == 'up':
						delete_plus(i - 1, j)
					if side == 'down':
						delete_plus(i + 1, j)
					if side == 'left':
						delete_plus(i, j - 1)
					if side == 'right':
						delete_plus(i, j + 1)
					flag = False
	if flag:
		n = True
		for row in area:
			if '#' in row:
				n = False
		if n:
			print('YES')
		else:
			print('NO')
		break


n = int(input())
a = [list(input()) for i in range(n)]
for i in range(n):
	for j in range(n):
		if a[i][j] == '#':
			if i < n - 2 and j >= 1 and (j <= n - 2) and (a[i + 1][j - 1] == '#') and (a[i + 1][j] == '#') and (a[i + 1][j + 1] == '#') and (a[i + 2][j] == '#'):
				a[i][j] = '.'
				a[i + 1][j - 1] = '.'
				a[i + 1][j] = '.'
				a[i + 1][j + 1] = '.'
				a[i + 2][j] = '.'
			else:
				print('NO')
				return
print('YES')


n = int(input())
a = [list(input()) for i in range(n)]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == a[i - 1][j] == a[i + 1][j] == a[i][j - 1] == a[i][j + 1] == '#':
			a[i][j] = a[i - 1][j] = a[i + 1][j] = a[i][j - 1] = a[i][j + 1] = '.'
print('NO' if sum((a[i].count('#') for i in range(n))) else 'YES')


def main():
	h = int(input())
	l = [c == '#' for _ in range(h) for c in input()]
	if not (l[0] or l[-1] or sum(l) % 5):
		l[-1] = True
		(w, idx) = (len(l) // h, 0)
		lim = (h - 2) * w - 2
		pattern = (0, w - 1, w, w + 1, 2 * w)
		while True:
			idx = l.index(True, idx + 1)
			if idx > lim:
				break
			if all((l[_ + idx] for _ in pattern)):
				for _ in pattern:
					l[_ + idx] = False
			else:
				break
		l[-1] = False
	print(('YES', 'NO')[any(l)])
main()


def valid(a, b, c):
	return a[1] == '#' and b == ['#', '#', '#'] and (c[1] == '#')
n = int(input())
arr = []
for i in range(n):
	arr += [list(input())]
for i in range(n - 2):
	for j in range(n - 2):
		if valid(arr[i][j:j + 3], arr[i + 1][j:j + 3], arr[i + 2][j:j + 3]):
			arr[i][j + 1] = '.'
			arr[i + 1][j:j + 3] = '...'
			arr[i + 2][j + 1] = '.'
for i in range(n):
	for j in range(n):
		if arr[i][j] == '#':
			print('NO')
			exit()
print('YES')


n = int(input())
L = [input() for i in range(n)]
L1 = [[0 for i in range(n)] for j in range(n)]
try:
	for i in range(n):
		for j in range(n):
			if L[i][j] == '#' and L1[i][j] == 0:
				if L1[i + 1][j] == L1[i + 2][j] == L1[i + 1][j + 1] == L1[i + 1][j - 1] == 0 and L[i + 1][j] == L[i + 2][j] == L[i + 1][j + 1] == L[i + 1][j - 1] == '#':
					L1[i + 1][j] = L1[i + 2][j] = L1[i + 1][j + 1] = L1[i + 1][j - 1] = 1
				else:
					exit()
except:
	print('NO')
	exit()
print('YES')


mat = []
n = int(input())
for i in range(0, n):
	line = list(input())
	mat.append([])
	for j in range(0, n):
		if line[j] == '.':
			mat[i].append(0)
		else:
			mat[i].append(1)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if mat[i][j] == 1 and mat[i + 1][j] == 1 and (mat[i - 1][j] == 1) and (mat[i][j + 1] == 1) and (mat[i][j - 1] == 1):
			mat[i][j] = 2
			mat[i + 1][j] = 2
			mat[i - 1][j] = 2
			mat[i][j + 1] = 2
			mat[i][j - 1] = 2
unused_harshtags = 0
for i in range(0, n):
	for j in range(0, n):
		if mat[i][j] == 1:
			unused_harshtags += 1
if unused_harshtags > 0:
	print('NO')
else:
	print('YES')


import sys
num_lines = int(input())
lines = []
hash_count = 0
for i in range(num_lines):
	tmp = input()
	lines.append([i for i in tmp])
	hash_count = hash_count + tmp.count('#')
for i in range(len(lines)):
	for j in range(len(lines[i])):
		if lines[i][j] == '#':
			try:
				if lines[i + 1][j - 1] == '#' and lines[i + 1][j] == '#' and (lines[i + 1][j + 1] == '#') and (lines[i + 2][j] == '#'):
					lines[i + 1][j - 1] = '.'
					lines[i + 1][j] = '.'
					lines[i + 1][j + 1] = '.'
					lines[i + 2][j] = '.'
					hash_count = hash_count - 5
			except:
				print('NO')
				return
if hash_count == 0:
	print('YES')
else:
	print('NO')


n = int(input())
x = [list(input()) for i in range(n)]
y = [['.' for j in range(n)] for i in range(n)]
error = False
for i in range(n):
	for j in range(n):
		if x[i][j] == '.' and y[i][j] == '.':
			continue
		elif x[i][j] == '.' and y[i][j] == '#':
			error = True
			break
		elif x[i][j] == '#' and y[i][j] == '.':
			if j == 0 or j == n - 1 or i > n - 3 or (y[i][j] == '#' or y[i + 1][j - 1] == '#' or y[i + 1][j] == '#' or (y[i + 1][j + 1] == '#') or (y[i + 2][j] == '#')):
				error = True
				break
			else:
				y[i][j] = '#'
				y[i + 1][j - 1] = '#'
				y[i + 1][j] = '#'
				y[i + 1][j + 1] = '#'
				y[i + 2][j] = '#'
if not error:
	print('YES')
else:
	print('NO')


def cross(n, lst):
	for i in range(n):
		for j in range(n):
			if lst[i][j] == '#':
				if i < n - 2 and 1 <= j <= n - 2 and (lst[i + 1][j - 1] == '#') and (lst[i + 1][j] == '#') and (lst[i + 1][j + 1] == '#') and (lst[i + 2][j] == '#'):
					lst[i][j] = '.'
					lst[i + 1][j - 1] = '.'
					lst[i + 1][j] = '.'
					lst[i + 1][j + 1] = '.'
					lst[i + 2][j] = '.'
				else:
					return 'NO'
	return 'YES'
N = int(input())
a = [list(input()) for i in range(N)]
print(cross(N, a))


def fits(x, y):
	global n
	return x >= 0 and x < n and (y >= 0) and (y < n)

def paint(x, y):
	global a
	a[x][y] = '.'
	a[x - 1][y] = '.'
	a[x + 1][y] = '.'
	a[x][y - 1] = '.'
	a[x][y + 1] = '.'

def check(x, y):
	global a
	dx = [0, 0, -1, 1]
	dy = [1, -1, 0, 0]
	cnt = 0
	for i in range(4):
		if fits(x + dx[i], y + dy[i]) and a[x + dx[i]][y + dy[i]] == '#':
			cnt += 1
	if a[x][y] == '#':
		cnt += 1
	if cnt == 5:
		paint(x, y)
n = int(input())
a = []
for i in range(n):
	a.append(list(input()))
for i in range(n):
	for j in range(n):
		check(i, j)
cnt = 0
for el in a:
	for el2 in el:
		if el2 == '#':
			cnt += 1
if cnt == 0:
	print('YES')
else:
	print('NO')


t = []
n = int(input())
for j in range(n):
	y = list(input())
	t.append(y)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if t[i][j] == '#' and t[i + 1][j] == '#' and (t[i - 1][j] == '#') and (t[i][j + 1] == '#') and (t[i][j - 1] == '#'):
			t[i][j] = 'a'
			t[i + 1][j] = 'a'
			t[i - 1][j] = 'a'
			t[i][j + 1] = 'a'
			t[i][j - 1] = 'a'
h = 0
for i in t:
	if '#' in i:
		print('NO')
		h += 1
		break
if h == 0:
	print('YES')


h = int(input())
l = [c == '#' for _ in range(h) for c in input()]
w = len(l) // h
cross = (0, w - 1, w, w + 1, 2 * w)
for i in range(1, (h - 2) * w - 1):
	if all((l[_ + i] for _ in cross)):
		for _ in cross:
			l[_ + i] = False
print(('YES', 'NO')[any(l)])


n = int(input())
m = [list(input()) for i in range(n)]

def test(m, n):
	for r in range(n):
		for c in range(n):
			if m[r][c] == '#':
				if c == 0 or c == n - 1 or r >= n - 2:
					return False
				elif m[r + 1][c - 1] == '#' and m[r + 1][c] == '#' and (m[r + 1][c + 1] == '#') and (m[r + 2][c] == '#'):
					m[r + 1][c - 1] = '.'
					m[r + 1][c] = '.'
					m[r + 1][c + 1] = '.'
					m[r + 2][c] = '.'
				else:
					return False
	return True
print('YES' if test(m, n) else 'NO')


c = set()
for i in range(int(input())):
	row = input()
	s = [(i, j) for j in range(len(row)) if row[j] == '#']
	c |= set(s)
	for (i, j) in s:
		p = set([(i, j), (i - 1, j), (i - 1, j - 1), (i - 1, j + 1), (i - 2, j)])
		if p <= c:
			c -= p
print('YNEOS'[len(c) != 0::2])


n = int(input())
s = [['.'] * n] * n
for i in range(0, n):
	s[i] = list(input())
flag = 1
for i in range(0, n - 2):
	for j in range(1, n - 1):
		if s[i][j] == '#':
			flag &= s[i + 1][j] == '#'
			flag &= s[i + 1][j - 1] == '#'
			flag &= s[i + 1][j + 1] == '#'
			flag &= s[i + 2][j] == '#'
			flag &= s[i][j] == '#'
			s[i + 1][j] = '.'
			s[i + 1][j - 1] = '.'
			s[i + 1][j + 1] = '.'
			s[i + 2][j] = '.'
			s[i][j] = '.'
for i in range(0, n):
	for j in range(0, n):
		flag &= s[i][j] == '.'
if flag == 1:
	print('YES')
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	arr = []
	for _ in range(n):
		arr.append(list(input()))
	for r in range(n):
		for c in range(n):
			try:
				if arr[r][c] == '#' and arr[r + 1][c] == '#' and (arr[r - 1][c] == '#') and (arr[r][c - 1] == '#') and (arr[r][c + 1] == '#'):
					arr[r][c] = '.'
					arr[r + 1][c] = '.'
					arr[r - 1][c] = '.'
					arr[r][c - 1] = '.'
					arr[r][c + 1] = '.'
			except:
				pass
	for r in range(n):
		for c in range(n):
			if arr[r][c] == '#':
				print('NO')
				exit()
	print('YES')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
cont = 0
matriz = []
for i in range(n):
	linha = list(input())
	matriz.append(linha)
	for i in range(n):
		if linha[i] == '#':
			cont += 1
if cont % 5 != 0:
	print('NO')
else:
	for i in range(0, n - 1):
		for j in range(1, n):
			if matriz[i][j] == '#' and i < n - 2 and (j < n - 1):
				if matriz[i + 1][j] != '#' or matriz[i + 2][j] != '#' or matriz[i + 1][j - 1] != '#' or (matriz[i + 1][j + 1] != '#'):
					continue
				else:
					matriz[i][j] = '.'
					matriz[i + 1][j] = '.'
					matriz[i + 2][j] = '.'
					matriz[i + 1][j - 1] = '.'
					matriz[i + 1][j + 1] = '.'
					cont -= 5
	if cont == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
matriz = []
yes = True
for i in range(n):
	matriz.append(list(input()))
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matriz[i][j] == '#' and matriz[i - 1][j] == '#' and (matriz[i + 1][j] == '#') and (matriz[i][j - 1] == '#') and (matriz[i][j + 1] == '#'):
			matriz[i][j] = '.'
			matriz[i - 1][j] = '.'
			matriz[i + 1][j] = '.'
			matriz[i][j - 1] = '.'
			matriz[i][j + 1] = '.'
for i in range(n):
	for j in range(n):
		if matriz[i][j] != '.':
			print('NO')
			yes = False
			break
	if yes == False:
		break
if yes:
	print('YES')


n = int(input())
a = [[0] * n for i in range(n)]
ans = 'YES'
for i in range(n):
	s = input()
	for j in range(n):
		if s[j] == '#':
			a[i][j] = 1
for i in range(n - 2):
	for j in range(1, n - 1):
		if a[i][j] == 1:
			if a[i + 1][j] == 1 and a[i + 2][j] == 1 and (a[i + 1][j - 1] == 1) and (a[i + 1][j + 1] == 1):
				a[i][j] = 0
				a[i + 1][j] = 0
				a[i + 2][j] = 0
				a[i + 1][j - 1] = 0
				a[i + 1][j + 1] = 0
			else:
				ans = 'NO'
for i in range(n):
	if sum(a[i]) != 0:
		ans = 'NO'
print(ans)


def check():
	for i in range(n):
		for j in range(n):
			if board[i][j] == '#':
				return False
	return True
n = int(input())
board = []
for i in range(n):
	board.append([char for char in input()])
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if board[i][j] == '#' and board[i][j - 1] == board[i][j + 1] == board[i - 1][j] == board[i + 1][j] == '#':
			board[i][j] = board[i][j - 1] = board[i][j + 1] = board[i - 1][j] = board[i + 1][j] = '@'
print('YES' if check() else 'NO')


def f(a, b, n, s):
	if b == 0 or b + 1 >= n or a + 2 >= n:
		return True
	if not (s[a + 1][b - 1] == '#' and s[a + 1][b] == '#' and (s[a + 1][b + 1] == '#') and (s[a + 2][b] == '#')):
		return True
	(s[a][b], s[a + 1][b - 1], s[a + 1][b], s[a + 1][b + 1], s[a + 2][b]) = ('.', '.', '.', '.', '.')
	return False

def code():
	n = int(input())
	s = [[0 for i in range(n)] for j in range(n)]
	for i in range(n):
		t = input()
		for j in range(n):
			s[i][j] = t[j]
	for i in range(n):
		for j in range(n):
			if s[i][j] == '#':
				if f(i, j, n, s):
					print('NO')
					return 1
	print('YES')
	return 1
code()


n = int(input())
a = [list(input()) for i in range(n)]
for x in range(n):
	for y in range(n):
		if a[x][y] == '#':
			for (dx, dy) in ((1, -1), (1, 0), (1, 1), (2, 0)):
				xx = x + dx
				yy = y + dy
				if xx < 0 or xx >= n or yy < 0 or (yy >= n) or (a[xx][yy] != '#'):
					print('NO')
					exit(0)
				else:
					a[xx][yy] = '.'
print('YES')


k = int(input())
a = []
for i in range(k):
	ai = []
	s = input()
	for ch in s:
		if ch != '.':
			ai.append(1)
		else:
			ai.append(0)
	a.append(ai)
failed = False
for i in range(k):
	for j in range(k):
		if a[i][j] == 1:
			if j == 0 or j == k - 1 or i > k - 3:
				failed = True
				break
			if a[i + 1][j - 1] == a[i + 1][j] == a[i + 1][j + 1] == a[i + 2][j] == 1:
				a[i][j] = 0
				a[i + 1][j - 1] = 0
				a[i + 1][j] = 0
				a[i + 1][j + 1] = 0
				a[i + 2][j] = 0
			else:
				failed = True
				break
	if failed:
		break
if not failed:
	print('YES')
else:
	print('NO')


def solve(n, lst):
	for i in range(n):
		for j in range(n):
			if lst[i][j] == '#':
				if i < n - 2 and 1 <= j <= n - 2 and (lst[i + 1][j - 1] == '#') and (lst[i + 1][j] == '#') and (lst[i + 1][j + 1] == '#') and (lst[i + 2][j] == '#'):
					lst[i][j] = '.'
					lst[i + 1][j - 1] = '.'
					lst[i + 1][j] = '.'
					lst[i + 1][j + 1] = '.'
					lst[i + 2][j] = '.'
				else:
					return 'NO'
	return 'YES'
n = int(input())
g = []
for i in range(n):
	g.append(list(input()))
print(solve(n, g))


n = int(input())
A = [list(input()) for _ in range(n)]
for x in range(1, n - 1):
	for y in range(1, n - 1):
		if A[x - 1][y] == '#' and A[x + 1][y] == '#' and (not '.' in A[x][y - 1:y + 2]):
			A[x][y - 1:y + 2] = '...'
			(A[x - 1][y], A[x + 1][y]) = '..'
print('NO' if any(('#' in row for row in A)) else 'YES')


import math
for m in range(1, 2):
	n = int(input())
	arr = []
	for i in range(n):
		a = list(input())
		arr.append(a)
	left = 0
	for i in range(n - 2):
		for j in range(n):
			if j >= 1 and j <= n - 2 and (arr[i][j] == '#'):
				hash1 = arr[i][j]
				hash2 = arr[i + 1][j]
				hash3 = arr[i + 1][j + 1]
				hash4 = arr[i + 1][j - 1]
				hash5 = arr[i + 2][j]
				if hash1 == hash2 == hash3 == hash4 == hash5 == '#':
					arr[i][j] = 'x'
					arr[i + 1][j] = 'x'
					arr[i + 1][j + 1] = 'x'
					arr[i + 1][j - 1] = 'x'
					arr[i + 2][j] = 'x'
				else:
					left += 1
			if arr[i][j] == '#':
				left += 1
	if arr[n - 1].count('#') >= 1 or arr[n - 2].count('#') >= 1:
		left += 1
	if left == 0:
		print('YES')
	else:
		print('NO')


def pos_possivel(i, j, n):
	if i < 0 or j < 0:
		return False
	if i >= n or j >= n:
		return False
	return True

def posso_desenhar_cruz(board, n, i, j):
	board[i][j] = '.'
	for k in range(-1, 2):
		if not pos_possivel(i + 1, j + k, n):
			return False
		if board[i + 1][j + k] == '.':
			return False
		board[i + 1][j + k] = '.'
	if not pos_possivel(i + 2, j, n):
		return False
	if board[i + 2][j] == '.':
		return False
	board[i + 2][j] = '.'
	return True

def solve(board, c_count, n):
	if c_count % 5 != 0:
		return False
	for i in range(n):
		for j in range(n):
			if board[i][j] == '#':
				if not posso_desenhar_cruz(board, n, i, j):
					return False
	return True
n = int(input())
board = []
c_count = 0
for i in range(n):
	line = []
	texto = [c for c in input()]
	for j in range(n):
		line.append(texto[j])
		if texto[j] == '#':
			c_count += 1
	board.append(line)
if solve(board, c_count, n):
	print('YES')
else:
	print('NO')


grid = []
n = 0

def main():
	global grid, n

	def clear(i, j):
		if i - 1 < 0 or i + 1 >= n or j < 0 or (j + 2 >= n):
			return False
		if grid[i][j] == '.' or grid[i][j + 1] == '.' or grid[i][j + 2] == '.':
			return False
		grid[i][j] = '.'
		grid[i][j + 1] = '.'
		grid[i][j + 2] = '.'
		if grid[i + 1][j + 1] == '.' or grid[i - 1][j + 1] == '.':
			return False
		grid[i + 1][j + 1] = '.'
		grid[i - 1][j + 1] = '.'
		return True
	n = int(input())
	for i in range(n):
		grid.append(list(input()))
	for j in range(n):
		for i in range(n):
			if grid[i][j] == '#':
				if not clear(i, j):
					return False
	for i in range(n):
		for j in range(n):
			if grid[i][j] == '#':
				return False
	return True
print('YES' if main() else 'NO')


def f(a, b, c):
	if a[1] == '#' and b == ['#', '#', '#'] and (c[1] == '#'):
		return 1
	return 0
n = int(input())
a = []
for i in range(n):
	a.append(list(input()))
for i in range(n - 2):
	for j in range(n - 2):
		if f(a[i][j:j + 3], a[i + 1][j:j + 3], a[i + 2][j:j + 3]) != 0:
			a[i][j + 1] = '.'
			a[i + 1][j:j + 3] = '...'
			a[i + 2][j + 1] = '.'
for i in range(n):
	for j in range(n):
		if a[i][j] == '#':
			print('NO')
			exit(0)
print('YES')


n = int(input())
s = []
for _ in range(n):
	s.append(list(input()))
for i in range(n):
	for j in range(n):
		if s[i][j] == '#':
			if i > n - 3:
				print('NO')
				exit(0)
			if j == 0 or j == n - 1:
				print('NO')
				exit(0)
			if s[i + 1][j - 1] == '#' and s[i + 1][j] == '#' and (s[i + 1][j + 1] == '#') and (s[i + 2][j] == '#'):
				s[i + 1][j - 1] = '.'
				s[i + 1][j] = '.'
				s[i + 1][j + 1] = '.'
				s[i + 2][j] = '.'
			else:
				print('NO')
				exit(0)
print('YES')


def solve(grid, n):
	for i in range(n):
		for j in range(n):
			if i >= n - 2:
				if grid[i][j] == '#':
					return 'NO'
			elif grid[i][j] == '#':
				if grid[i + 1][j - 1] == '.' or grid[i + 1][j] == '.' or grid[i + 1][j + 1] == '.' or (grid[i + 2][j] == '.'):
					return 'NO'
				else:
					grid[i][j] = '.'
					grid[i + 1][j - 1] = '.'
					grid[i + 1][j] = '.'
					grid[i + 1][j + 1] = '.'
					grid[i + 2][j] = '.'
	return 'YES'
n = int(input())
grid = [list(input()) for _ in range(n)]
print(solve(grid, n))


def deleteCross(m, i, j):
	if i <= 0 or j <= 0 or i >= len(m) - 1 or (j >= len(m) - 1):
		return (m, False)
	if m[i][j] == '#' and m[i + 1][j] == '#' and (m[i - 1][j] == '#') and (m[i][j + 1] == '#') and (m[i][j - 1] == '#'):
		m[i][j] = m[i + 1][j] = m[i - 1][j] = m[i][j + 1] = m[i][j - 1] = '.'
		return (m, True)
	return (m, False)

def solve(m):
	for i in range(len(m)):
		for j in range(len(m)):
			if m[i][j] == '#':
				r1 = deleteCross(m, i + 1, j)
				if not r1[1]:
					return False
				m = r1[0]
	return True
n = int(input())
m = []
for i in range(n):
	m.append(list(input()))
print('YES' if solve(m) else 'NO')


from itertools import chain
n = int(input())
tab = [list((c == '#' for c in input())) for _ in range(n)]
flag = {True}.issubset(chain.from_iterable(tab))
if flag:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if tab[i - 1][j] and tab[i][j - 1] and tab[i][j] and tab[i][j + 1] and tab[i + 1][j]:
				tab[i - 1][j] = False
				tab[i][j - 1] = False
				tab[i][j] = False
				tab[i][j + 1] = False
				tab[i + 1][j] = False
	flag = {True}.issubset(chain.from_iterable(tab))
if flag:
	print('NO')
else:
	print('YES')


n = int(input())
l = []
s = 0
for i in range(n):
	o = input()
	s += o.count('#')
	l += [list(o)]
q = [[1 for i in range(n)] for i in range(n)]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == '#' and q[i][j]:
			if l[i + 1][j] == '#' and q[i + 1][j]:
				if l[i - 1][j] == '#' and q[i - 1][j]:
					if l[i][j + 1] == '#' and q[i][j + 1]:
						if l[i][j - 1] == '#' and q[i][j - 1]:
							s -= 5
							q[i + 1][j] = q[i - 1][j] = q[i][j - 1] = q[i][j + 1] = 0
print('YNEOS'[s != 0::2])


n = int(input())
l = []
for i in range(n):
	l.append(list(input()))
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == l[i][j + 1] == l[i][j - 1] == l[i - 1][j] == l[i + 1][j] == '#':
			l[i][j] = l[i][j + 1] = l[i][j - 1] = l[i - 1][j] = l[i + 1][j] = '.'
for i in range(n):
	if l[i].count('#') > 0:
		c = 1
		break
if c == 0:
	print('YES')
else:
	print('NO')


from typing import List

def cross_neighbors(i: int, j: int):
	return [(i + 1, j - 1), (i + 1, j), (i + 1, j + 1), (i + 2, j)]

def solve(n: int, board: List[List[str]]) -> str:
	for i in range(0, n - 2):
		for j in range(1, n - 1):
			if board[i][j] == '#':
				board[i][j] = '.'
				for (x, y) in cross_neighbors(i, j):
					if board[x][y] == '.':
						return 'NO'
					if board[x][y] == '#':
						board[x][y] = '.'
	return ['YES', 'NO'][any((board[i][j] == '#' for i in range(n) for j in range(n)))]
n = int(input())
board = [list(input()) for _ in range(n)]
print(solve(n, board))


n = int(input())
rows = [list(input()) for x in range(n)]
a = 0
for x in rows:
	a += x.count('#')
if a % 5 == 0:
	for x in range(1, n - 1):
		for y in range(1, n - 1):
			if rows[x][y] == '#' and rows[x - 1][y] == '#' and (rows[x + 1][y] == '#') and (rows[x][y - 1] == '#') and (rows[x][y + 1] == '#'):
				rows[x][y] = rows[x - 1][y] = rows[x + 1][y] = rows[x][y - 1] = rows[x][y + 1] = '.'
	for x in rows:
		for y in x:
			if y == '#':
				print('NO')
				break
		else:
			continue
		break
	else:
		print('YES')
else:
	print('NO')


def str_inp(n):
	return [list(input()) for x in range(n)]
n = int(input())
a = str_inp(n)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == '#':
			exp = a[i - 1][j] == '#' and a[i + 1][j] == '#' and (a[i][j - 1] == '#') and (a[i][j + 1] == '#')
			if exp:
				a[i - 1][j] = a[i + 1][j] = a[i][j - 1] = a[i][j + 1] = a[i][j] = '.'
for i in range(n):
	for j in range(n):
		if a[i][j] == '#':
			exit(print('NO'))
print('YES')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
n = L()[0]
A = [list(input()) for i in range(n)]

def pos(A, count):
	if count == 0:
		return 1
	for i in range(n):
		for j in range(n):
			if A[i][j] == '#':
				try:
					if A[i - 1][j] + A[i + 1][j] + A[i][j - 1] + A[i][j + 1] == '####':
						A[i][j] = '.'
						A[i - 1][j] = '.'
						A[i + 1][j] = '.'
						A[i][j - 1] = '.'
						A[i][j + 1] = '.'
						if pos(A, count - 5):
							return 1
						return 0
						A[i][j] = '#'
						A[i - 1][j] = '#'
						A[i + 1][j] = '#'
						A[i][j - 1] = '#'
						A[i][j + 1] = '#'
				except:
					continue
count = 0
for row in A:
	for ele in row:
		if ele == '#':
			count += 1
if count % 5:
	print('NO')
	exit()
if pos(A, count):
	print('YES')
else:
	print('NO')
endtime = time.time()


n = int(input())
s = [list(input()) for _ in range(n)]

def TryCross(i, j):
	if 0 <= i < n - 2 and 0 < j < n - 1:
		c = [(i, j), (i + 1, j - 1), (i + 1, j), (i + 1, j + 1), (i + 2, j)]
		if not all((s[x][y] == '#' for (x, y) in c)):
			return False
		for (x, y) in c:
			s[x][y] = '.'
		return True
	return False
for i in range(n):
	for j in range(n):
		if s[i][j] == '#' and (not TryCross(i, j)):
			print('NO')
			exit()
print('YES')


n = int(input())
a = [[] for i in range(n)]
for i in range(n):
	s = input().strip()
	for j in s:
		a[i] += [j]
kr = 0
for i in range(n):
	for j in range(n):
		if a[i][j] == '#':
			kr += 1
		if 0 < i < n - 1 and 0 < j < n - 1 and (a[i][j] == '#'):
			if a[i][j - 1] == a[i][j + 1] == a[i - 1][j] == a[i + 1][j] == '#':
				kr -= 3
				(a[i][j - 1], a[i][j + 1], a[i - 1][j], a[i + 1][j], a[i][j]) = ('.', '.', '.', '.', '.')
if kr:
	print('NO')
else:
	print('YES')


n = int(input())
arr = []
for i in range(n):
	arr.append(list(input()))
k = 1
for i in range(n):
	for j in range(n):
		if arr[i][j] == '#':
			if i + 2 <= n - 1 and j - 1 >= 0 and (j + 1 <= n - 1):
				if arr[i + 1][j - 1] == '#' and arr[i + 1][j] == '#' and (arr[i + 1][j + 1] == '#') and (arr[i + 2][j] == '#'):
					arr[i + 1][j - 1] = '.'
					arr[i + 1][j] = '.'
					arr[i + 1][j + 1] = '.'
					arr[i + 2][j] = '.'
					arr[i][j] = '.'
				else:
					k = 0
					break
			else:
				k = 0
				break
if k == 1:
	print('YES')
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	l.append(list(input()))
f = 0
for j in range(n - 2):
	for k in range(n):
		if l[j][k] == '#':
			if l[j + 1][k] == '#':
				if -1 < k - 1 < n:
					if l[j + 1][k - 1] == '#':
						if -1 < k + 1 < n:
							if l[j + 1][k + 1] == '#':
								if l[j + 2][k] == '#':
									l[j][k] = '.'
									l[j + 1][k] = '.'
									l[j + 1][k - 1] = '.'
									l[j + 1][k + 1] = '.'
									l[j + 2][k] = '.'
								else:
									f = 1
									break
							else:
								f = 1
								break
						else:
							f = 1
							break
					else:
						f = 1
						break
				else:
					f = 1
					break
			else:
				f = 1
				break
if f != 1:
	for j in range(n - 2, n):
		for k in range(n):
			if l[j][k] == '#':
				f = 1
		if f == 1:
			break
if f == 0:
	print('YES')
else:
	print('NO')


n = int(input())
board = [''] * n
c = 0
for i in range(n):
	board[i] = list(input())
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if board[i][j] == '#' and board[i - 1][j] == '#' and (board[i + 1][j] == '#') and (board[i][j - 1] == '#') and (board[i][j + 1] == '#'):
			board[i][j] = '.'
			board[i - 1][j] = '.'
			board[i + 1][j] = '.'
			board[i][j - 1] = '.'
			board[i][j + 1] = '.'
c = sum((board[i].count('#') for i in range(n)))
print('YES') if c == 0 else print('NO')


def cross(i, j, v, n):
	v[i * n + j] = '.'
	if v[(i + 1) * n + j] == '#':
		v[(i + 1) * n + j] = '.'
		if v[(i + 2) * n + j] == '#':
			v[(i + 2) * n + j] = '.'
			if v[(i + 1) * n + j + 1] == '#':
				v[(i + 1) * n + j + 1] = '.'
				if v[(i + 1) * n + j - 1] == '#':
					v[(i + 1) * n + j - 1] = '.'
					return True
				else:
					return False
			else:
				return False
		else:
			return False
	else:
		return False
n = int(input())
v = ['.'] * n * n
ans = True
for i in range(n):
	s = input()
	for j in range(n):
		v[i * n + j] = s[j]
for i in range(n):
	if ans:
		for j in range(n):
			if v[i * n + j] == '#':
				if j == 0 or j == n - 1 or i > n - 3:
					ans = False
					break
				else:
					ans = cross(i, j, v, n)
	else:
		break
if ans:
	print('YES')
else:
	print('NO')


def verificar_cruzes(matriz, n):
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if matriz[i][j] == '#':
				if matriz[i - 1][j] == '#' and matriz[i + 1][j] == '#' and (matriz[i][j + 1] == '#') and (matriz[i][j - 1] == '#'):
					matriz[i][j] = '.'
					matriz[i + 1][j] = '.'
					matriz[i - 1][j] = '.'
					matriz[i][j + 1] = '.'
					matriz[i][j - 1] = '.'
	for i in range(n):
		for j in range(n):
			if matriz[i][j] == '#':
				print('NO')
				return
	print('YES')

def main():
	matriz = []
	velhas = 0
	n = int(input())
	for i in range(n):
		linha = input()
		for i in range(n):
			matriz.append([])
			if linha[i] == '#':
				velhas += 1
				matriz[i].append('#')
			else:
				matriz[i].append('.')
	if velhas % 5 != 0:
		print('NO')
		return
	if matriz[0][0] == '#' or matriz[n - 1][0] == '#' or matriz[0][n - 1] == '#' or (matriz[n - 1][n - 1] == '#'):
		print('NO')
		return
	else:
		verificar_cruzes(matriz, n)
main()


def check_board(b):
	possible = 'YES'
	b_size = len(b)
	for i in range(board_size):
		for j in range(b_size):
			if b[i][j] == '#':
				if j == 0 or j == b_size - 1 or i > b_size - 3:
					possible = 'NO'
					return possible
				elif b[i + 1][j - 1] != '#' or b[i + 1][j] != '#' or b[i + 1][j + 1] != '#' or (b[i + 2][j] != '#'):
					possible = 'NO'
					return possible
				else:
					b[i + 1][j - 1] = 'used'
					b[i + 1][j] = 'used'
					b[i + 1][j + 1] = 'used'
					b[i + 2][j] = 'used'
	return possible
board_size = int(input())
board = []
for n in range(board_size):
	line = list(input())
	board.append(line)
print(check_board(board))


n = int(input())
a = [list(input()) for _ in range(n)]

def check(i, j):
	if (i, j) in [(0, 0), (0, n - 1), (n - 1, 0), (n - 1, n - 1)]:
		return False
	if i >= n - 2 or j == 0 or j == n - 1:
		return False
	if a[i + 1][j] != '#' or a[i + 1][j - 1] != '#' or a[i + 1][j + 1] != '#' or (a[i + 2][j] != '#'):
		return False
	a[i + 1][j] = '.'
	a[i + 1][j + 1] = '.'
	a[i + 1][j - 1] = '.'
	a[i + 2][j] = '.'
	a[i][j] = '.'
	return True
for i in range(n):
	for j in range(n):
		if a[i][j] == '#':
			if not check(i, j):
				print('NO')
				exit()
print('YES')


n = int(input())
arr = [list(input()) for _ in range(n)]
for i in range(n):
	for j in range(n):
		if arr[i][j] == '#':
			if i > 0 and arr[i - 1][j] == '#' and (j > 0) and (arr[i][j - 1] == '#') and (i < n - 1) and (arr[i + 1][j] == '#') and (j < n - 1) and (arr[i][j + 1] == '#'):
				arr[i][j] = '.'
				arr[i - 1][j] = '.'
				arr[i + 1][j] = '.'
				arr[i][j - 1] = '.'
				arr[i][j + 1] = '.'
f = True
for i in arr:
	if '#' in i:
		f = False
print('YES' if f else 'NO')


tam = int(input())
matriz = []
contador = 0
for i in range(tam):
	matriz.append(list(input()))
	contador += matriz[i].count('#')
if contador % 5 != 0:
	print('NO')
else:
	i = 1
	j = 1
	while i < tam - 1:
		j = 1
		while j < tam - 1:
			if matriz[i][j] == '#':
				if matriz[i - 1][j] == '#' and matriz[i][j - 1] == '#' and (matriz[i + 1][j] == '#') and (matriz[i][j + 1] == '#'):
					matriz[i - 1][j] = '.'
					matriz[i][j - 1] = '.'
					matriz[i + 1][j] = '.'
					matriz[i][j + 1] = '.'
					matriz[i][j] = '.'
			j += 1
		i += 1
	falhou = False
	for i in range(tam):
		if matriz[i].count('#') != 0:
			print('NO')
			falhou = True
			break
	if not falhou:
		print('YES')


n = int(input())
a = []
for i in range(n):
	a.append(list(input()))

def check_range(i, j):
	if j - 1 >= 0 and j + 1 < n and (i + 2 < n):
		if a[i + 1][j - 1] == '#' and a[i + 1][j + 1] == '#' and (a[i + 1][j] == '#') and (a[i + 2][j] == '#'):
			return True
		return False
	else:
		return False
res = True
for i in range(n):
	for j in range(n):
		if a[i][j] == '#':
			if check_range(i, j):
				a[i][j] = 'X'
				a[i + 1][j - 1] = 'X'
				a[i + 1][j] = 'X'
				a[i + 1][j + 1] = 'X'
				a[i + 2][j] = 'X'
			else:
				res = False
				break
if res:
	print('YES')
else:
	print('NO')


from sys import *
from math import *

def solve():
	n = int(input())
	f = []
	for i in range(n):
		f.append([e for e in input()])
	k = 1
	leftover = 0
	for i in range(n):
		for j in range(n):
			if f[i][j] == '#':
				if i + k < n and j + k < n and (i - k >= 0) and (j - k >= 0) and (f[i + k][j] == '#') and (f[i][j + k] == '#') and (f[i - k][j] == '#') and (f[i][j - k] == '#'):
					(f[i + k][j], f[i - k][j], f[i][j + k], f[i][j - k], f[i][j]) = ['*'] * 5
	for i in range(n):
		for j in range(n):
			if f[i][j] == '#':
				leftover += 1
	return leftover == 0

def main():
	t = 1
	for ii in range(t):
		print('YES' if solve() else 'NO')
main()


n = int(input())
al = []
sl = set()
for i in range(n):
	al.append(list(input()))
for i in range(n - 2):
	for j in range(1, n - 1):
		if al[i][j] == al[i + 1][j] == al[i + 1][j - 1] == al[i + 1][j + 1] == al[i + 2][j] == '#':
			al[i][j] = al[i + 1][j] = al[i + 1][j - 1] = al[i + 1][j + 1] = al[i + 2][j] = '.'
for i in range(n):
	sl = sl.union(set(al[i]))
if len(sl) == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = []
for i in range(n):
	a.append(list(input()))
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == '#' and a[i + 1][j] == '#' and (a[i - 1][j] == '#') and (a[i][j - 1] == '#') and (a[i][j + 1] == '#'):
			a[i][j] = '.'
			a[i][j + 1] = '.'
			a[i][j - 1] = '.'
			a[i + 1][j] = '.'
			a[i - 1][j] = '.'
for i in a:
	for j in i:
		if j == '#':
			print('NO')
			exit(0)
print('YES')


import sys
import bisect
from collections import Counter, defaultdict as dd

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
n = int(data())
a = []
for _ in range(n):
	a.append(list(data()))
b = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == '#' and a[i - 1][j] == '#' and (a[i][j - 1] == '#') and (a[i][j + 1] == '#') and (a[i + 1][j] == '#'):
			a[i][j] = '.'
			a[i - 1][j] = '.'
			a[i + 1][j] = '.'
			a[i][j - 1] = '.'
			a[i][j + 1] = '.'
for i in range(n):
	b += a[i].count('#')
if b == 0:
	print('YES')
else:
	print('NO')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = []
c = 0
c1 = 0
for _ in range(n):
	x = ls()
	c += x.count('#')
	l.append(x)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] + l[i - 1][j] + l[i + 1][j] + l[i][j - 1] + l[i][j + 1] == '#####':
			l[i][j] = '.'
			l[i - 1][j] = '.'
			l[i + 1][j] = '.'
			l[i][j - 1] = '.'
			l[i][j + 1] = '.'
			c1 += 5
print('YNEOS'[c1 != c::2])


import sys
lis = list()
n = int(input())
for i in range(n):
	lis.append(list(input()))
for line in range(1, n - 1):
	for j in range(1, n - 1):
		if lis[line][j] == '#' and lis[line + 1][j] == '#' and (lis[line - 1][j] == '#') and (lis[line][j + 1] == '#') and (lis[line][j - 1] == '#'):
			lis[line][j] = '.'
			lis[line + 1][j] = '.'
			lis[line - 1][j] = '.'
			lis[line][j + 1] = '.'
			lis[line][j - 1] = '.'
for i in lis:
	for j in i:
		if j == '#':
			print('NO')
			sys.exit()
print('YES')


def f():
	n = int(input())
	t = [list(input()) for i in range(n)]
	for i in range(n - 2):
		if t[i][0] == '#' or t[i][-1] == '#':
			return 'NO'
		for j in range(1, n - 1):
			if t[i][j] == '#':
				if '#' == t[i + 1][j - 1] == t[i + 1][j] == t[i + 1][j + 1] == t[i + 2][j]:
					t[i + 1][j - 1] = t[i + 1][j] = t[i + 1][j + 1] = t[i + 2][j] = '.'
				else:
					return 'NO'
	if '#' in t[-2] or '#' in t[-1]:
		return 'NO'
	return 'YES'
print(f())


def canDraw(n, matrix):
	can = True
	for i in range(n):
		for j in range(n):
			if matrix[i][j] == '#':
				if matrix[i + 1][j] == '#' and matrix[i + 2][j] == '#' and (matrix[i + 1][j - 1] == '#') and (matrix[i + 1][j + 1] == '#'):
					matrix[i][j] = '.'
					matrix[i + 1][j] = '.'
					matrix[i + 2][j] = '.'
					matrix[i + 1][j - 1] = '.'
					matrix[i + 1][j + 1] = '.'
				else:
					can = False
					break
		if not can:
			break
	return can
n = int(input())
matrix = []
hash = 0
for i in range(n):
	string = input()
	hash += string.count('#')
	matrix.append(list(string))
if hash % 5 != 0:
	print('NO')
elif canDraw(n, matrix):
	print('YES')
else:
	print('NO')


def checkPositions(i, j, matrix, visitados, n):
	positions = [[i + 1, j - 1], [i + 1, j], [i + 1, j + 1], [i + 2, j]]
	for [x, y] in positions:
		if x >= n or y >= n:
			return False
		if matrix[x][y] == '.' or visitados[x][y]:
			return False
		else:
			visitados[x][y] = True
	return True
n = int(input())
matrix = []
visitados = [[False for i in range(n)] for j in range(n)]
for i in range(n):
	matrix.append(input())
falhou = False
for i in range(n):
	for j in range(n):
		if matrix[i][j] == '#':
			if not visitados[i][j]:
				if not checkPositions(i, j, matrix, visitados, n):
					falhou = True
					break
	if falhou:
		break
if falhou:
	print('NO')
else:
	print('YES')


n = int(input())
a = []
for i in range(n):
	k = list(input())
	a.append(k)
l = 0
for i in range(1, len(a) - 1):
	for j in range(1, len(a) - 1):
		if a[i][j] == '#' and a[i + 1][j] == '#' and (a[i - 1][j] == '#') and (a[i][j + 1] == '#') and (a[i][j - 1] == '#'):
			l += 5
			a[i][j] = '+'
			a[i + 1][j] = '+'
			a[i - 1][j] = '+'
			a[i][j + 1] = '+'
			a[i][j - 1] = '+'
plu = 0
has = 0
for i in range(len(a)):
	plu += a[i].count('+')
	has += a[i].count('#')
if plu + has == l:
	print('YES')
else:
	print('NO')


def out(matri):
	verdade = True
	for i in matri:
		if '#' in i:
			verdade = False
	if verdade:
		print('YES')
	else:
		print('NO')

def main():
	n = int(input())
	matri = []
	for _ in range(n):
		matri.append(list(input()))
	for i in range(n):
		for j in range(n):
			if matri[i][j] == '.':
				continue
			devePintar = 0
			estaem = [j + 1 != n, j != 0, i != 0, i + 1 != n]
			if estaem[0] and matri[i][j + 1] == '#':
				devePintar += 1
			if estaem[1] and matri[i][j - 1] == '#':
				devePintar += 1
			if estaem[2] and matri[i - 1][j] == '#':
				devePintar += 1
			if estaem[3] and matri[i + 1][j] == '#':
				devePintar += 1
			if devePintar == 4:
				matri[i][j] = '.'
				if estaem[0] and matri[i][j + 1] == '#':
					matri[i][j + 1] = '.'
				if estaem[1] and matri[i][j - 1] == '#':
					matri[i][j - 1] = '.'
				if estaem[2] and matri[i - 1][j] == '#':
					matri[i - 1][j] = '.'
				if estaem[3] and matri[i + 1][j] == '#':
					matri[i + 1][j] = '.'
	out(matri)
main()


my = [0, 1, 1, 1, 2]
mx = [0, 0, -1, 1, 0]
n = int(input())
board = []
for i in range(n):
	board.append(list(input()))
flag = True
for i in range(n):
	for j in range(n):
		if board[i][j] == '#':
			for (dy, dx) in zip(my, mx):
				y = i + dy
				x = j + dx
				if y < 0 or y >= n or x < 0 or (x >= n):
					flag = False
					break
				if board[y][x] == '.':
					flag = False
				board[y][x] = '.'
	if flag == False:
		break
print('YES' if flag else 'NO')


import sys
n = int(sys.stdin.readline())
lines = []
for i in range(n):
	lines.append(list(sys.stdin.readline().strip()))

def check(lines, x, y, n):
	if x < 0 or x >= n or y < 0 or (y >= n):
		return False
	if lines[x][y] != '#':
		return False
	lines[x][y] = '.'
	return True

def tryPaint(lines, i, j, n):
	return check(lines, i, j, n) and check(lines, i - 1, j + 1, n) and check(lines, i, j + 1, n) and check(lines, i + 1, j + 1, n) and check(lines, i, j + 2, n)
failed = False
for j in range(n):
	for i in range(n):
		if lines[i][j] == '#':
			if not tryPaint(lines, i, j, n):
				failed = True
				break
		if failed:
			break
if not failed:
	for i in range(n):
		if '#' in set(lines[i]):
			failed = True
			break
if failed:
	print('NO')
else:
	print('YES')


n = int(input())
res = 'YES'
c = []
for i in range(n):
	c.append(['.'])
	r = input()
	for C in r:
		c[i].append(C)
for i in range(n):
	for j in range(n + 1):
		if c[i][j] == '#':
			if i >= n - 2 or j == n:
				res = 'NO'
				continue
			if c[i + 1][j] == '.' or c[i + 1][j - 1] == '.' or c[i + 1][j + 1] == '.':
				res = 'NO'
				continue
			if c[i + 2][j] == '.':
				res = 'NO'
			c[i][j] = '.'
			c[i + 1][j] = '.'
			c[i + 2][j] = '.'
			c[i + 1][j - 1] = '.'
			c[i + 1][j + 1] = '.'
print(res)


def main():
	n = int(input())
	grid = [list(input()) for _ in range(n)]
	neighbors = [(0, 0), (1, 0), (-1, 0), (0, 1), (0, -1)]
	for r in range(1, n - 1):
		for c in range(1, n - 1):
			coords2remove = []
			for neigh in neighbors:
				(a, b) = (r + neigh[0], c + neigh[1])
				if grid[a][b] == '#':
					coords2remove.append((a, b))
			if len(coords2remove) == 5:
				for (a, b) in coords2remove:
					grid[a][b] = '.'
	for r in range(n):
		for c in range(n):
			if grid[r][c] == '#':
				print('NO')
				return
	print('YES')
main()