An L-shape is a figure on gridded paper that looks like the first four pictures below. An L-shape contains exactly three shaded cells (denoted by *), which can be rotated in any way.

You are given a rectangular grid. Determine if it contains L-shapes only, where L-shapes can't touch an edge or corner. More formally:

Each shaded cell in the grid is part of exactly one L-shape, and

no two L-shapes are adjacent by edge or corner.

For example, the last two grids in the picture above do not satisfy the condition because the two L-shapes touch by corner and edge, respectively.


-----Input-----

The input consists of multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 100$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $n$ and $m$ ($1 \leq n, m \leq 50$) — the number of rows and columns in the grid, respectively.

Then $n$ lines follow, each containing $m$ characters. Each of these characters is either '.' or '*' — an empty cell or a shaded cell, respectively.


-----Output-----

For each test case, output "YES" if the grid is made up of L-shape that don't share edges or corners, and "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).


-----Examples-----

Input
10
6 10
........**
.**......*
..*..*....
.....**...
...*.....*
..**....**
6 10
....*...**
.**......*
..*..*....
.....**...
...*.....*
..**....**
3 3
...
***
...
4 4
.*..
**..
..**
..*.
5 4
.*..
**..
....
..**
..*.
3 2
.*
**
*.
2 3
*..
.**
3 2
..
**
*.
3 3
.**
*.*
**.
3 3
..*
.**
..*
Output
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO


-----Note-----

None

Difficulty: MEDIUM_HARD
Tags: Graph traversal

Implementation

Starter code:

Solutions:
def solve():
	(n, m) = map(int, input().split())
	g = [[1 if i == '*' else 0 for i in input()] for _ in range(n)]
	for i in range(n):
		for j in range(m):
			if g[i][j]:
				t = 0
				for (a, b) in [(0, -1), (0, 1), (1, 0), (-1, 0)]:
					if 0 <= i + a < n and 0 <= j + b < m and g[i + a][j + b]:
						t += 1
				for (a, b) in [(1, 1), (-1, 1), (-1, -1), (1, -1)]:
					if 0 <= i + a < n and 0 <= j + b < m and g[i + a][j + b]:
						t += 1
						if not g[i + a][j] and (not g[i][j + b]):
							return 'NO'
				if t != 2:
					return 'NO'
	return 'YES'
for _ in range(int(input())):
	print(solve())


def solve():
	(n, m) = map(lambda x: int(x), input().split())
	centers = [(0, 1), (0, -1), (1, 0), (-1, 0)]
	edges = [(-1, -1), (-1, 1), (1, -1), (1, 1)]
	mat = []
	for _ in range(n):
		mat.append(list(input()))
	for i in range(n):
		for j in range(m):
			if mat[i][j] == '*':
				t = 0
				for (a, b) in centers:
					if 0 <= i + a < n and 0 <= j + b < m and (mat[i + a][j + b] == '*'):
						t += 1
				for (a, b) in edges:
					if 0 <= i + a < n and 0 <= j + b < m and (mat[i + a][j + b] == '*'):
						t += 1
						if mat[i][j + b] != '*' and mat[i + a][j] != '*':
							return 'NO'
				if t != 2:
					return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	print(solve())


def p(points):
	if len(points) == 0:
		return False
	rs = set([r for (r, c) in points])
	cs = set([c for (r, c) in points])
	return len(rs) == 2 and len(cs) == 2

def is_l_shape(board, r, c):
	rows = len(board)
	cols = len(board[0])
	values = [(r, c)]
	points = []
	while len(values) > 0 and len(points) <= 3:
		(r2, c2) = values.pop()
		points.append((r2, c2))
		board[r2][c2] = '.'
		new_values = [(r2 + x, c2 + y) for x in range(-1, 2) for y in range(-1, 2)]
		filtered_values = [t for t in new_values if 0 <= t[0] < rows and 0 <= t[1] < cols and (board[t[0]][t[1]] == '*') and (t not in values)]
		for v in filtered_values:
			values.append(v)
	return len(points) == 3 and p(points)

def f(board):
	rows = len(board)
	cols = len(board[0])
	if rows == 1:
		return all([board[0][c] == '.' for c in range(cols)])
	if cols == 1:
		return all([board[r][0] == '.' for r in range(rows)])
	for r in range(rows):
		for c in range(cols):
			if board[r][c] == '*' and (not is_l_shape(board, r, c)):
				return False
	return True
t = int(input())
for i in range(t):
	(n, m) = [int(el) for el in input().split(' ')]
	board = []
	for r in range(n):
		row = list(input())
		board.append(row)
	if f(board):
		print('YES')
	else:
		print('NO')