Problem: Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:

  * Empty — '.' 
  * Wall — '#' 
  * Good person — 'G' 
  * Bad person — 'B' 



The only escape from the maze is at cell (n, m).

A person can move to a cell only if it shares a side with their current cell and does not contain a wall. Vivek wants to block some of the empty cells by replacing them with walls in such a way, that all the good people are able to escape, while none of the bad people are able to. A cell that initially contains 'G' or 'B' cannot be blocked and can be travelled through.

Help him determine if there exists a way to replace some (zero or more) empty cells with walls to satisfy the above conditions.

It is guaranteed that the cell (n,m) is empty. Vivek can also block this cell.

Input

The first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers n, m (1 ≤ n, m ≤ 50) — the number of rows and columns in the maze.

Each of the next n lines contain m characters. They describe the layout of the maze. If a character on a line equals '.', the corresponding cell is empty. If it equals '#', the cell has a wall. 'G' corresponds to a good person and 'B' corresponds to a bad person.

Output

For each test case, print "Yes" if there exists a way to replace some empty cells with walls to satisfy the given conditions. Otherwise print "No"

You may print every letter in any case (upper or lower).

Example

Input


6
1 1
.
1 2
G.
2 2
#B
G.
2 3
G.#
B#.
3 3
#B.
#..
GG.
2 2
#B
B.


Output


Yes
Yes
No
No
Yes
Yes

Note

For the first and second test cases, all conditions are already satisfied.

For the third test case, there is only one empty cell (2,2), and if it is replaced with a wall then the good person at (1,2) will not be able to escape.

For the fourth test case, the good person at (1,1) cannot escape.

For the fifth test case, Vivek can block the cells (2,3) and (2,2).

For the last test case, Vivek can block the destination cell (2, 2).

Solution (in PYTHON3):

Solution:


# from math import factorial as fac
from collections import defaultdict
# from copy import deepcopy
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
# print(f.readline())
sys.setrecursionlimit(10**2)

	
def print_case_iterable(case_num, iterable):
	print("Case #{}: {}".format(case_num," ".join(map(str,iterable))))

def print_case_number(case_num, iterable):
	print("Case #{}: {}".format(case_num,iterable))

def print_iterable(A):
	print (' '.join(A))

def read_int():
	return int(f.readline().strip())
def read_int_array():
	return [int(x) for x in f.readline().strip().split(" ")]
def rns():
	a =  [x for x in f.readline().split(" ")]
	return int(a[0]), a[1].strip()
def read_string():
	return list(f.readline().strip())
def ri():
	return int(f.readline().strip())
def ria():
	return [int(x) for x in f.readline().strip().split(" ")]
def rns():
	a =  [x for x in f.readline().split(" ")]
	return int(a[0]), a[1].strip()
def rs():
	return list(f.readline().strip())
def bi(x):
	return bin(x)[2:]





from collections import deque
import math
NUMBER = 10**9 + 7
# NUMBER = 998244353
def factorial(n) : 
	M = NUMBER
	f = 1
  
	for i in range(1, n + 1):  
		f = (f * i) % M # Now f never can  
						# exceed 10^9+7  
	return f
def mult(a,b):
	return (a * b) % NUMBER

def minus(a , b):
	return (a - b) % NUMBER

def plus(a , b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		g, y, x = egcd(b % a, a)
		return (g, x - (b // a) * y, y)

def modinv(a):
	m = NUMBER
	g, x, y = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m
def choose(n,k):
	if n < k:
		assert false
	return  mult(factorial(n), modinv(mult(factorial(k),factorial(n-k))))
from collections import deque, defaultdict 
import heapq


def bfs(b,n,m):
	s = set()
	# print('\n'.join(map(str,E.items())))
	ncc = 0 
	# print(b)
	for i in range(n):
		for j in range(m):
			v = (i,j)
			if b[i][j] == '#' or b[i][j] == '.' or v in s:
				continue
			if ncc == 1:
				return False
			q = deque([])
			s.add(v)
			q.append(v)
			# print(v)
			while len(q) > 0:
				k,l = q.popleft()
				# print(i,j)
				# print(s)
				# print(i,j+1, b[i][j+1])
				if k > 0 and b[k-1][l] != '#':
					if (k-1,l) not in s:
						s.add((k-1,l))
						q.append((k-1,l))

				if k < n-1 and b[k+1][l] != '#':
					if (k+1,l) not in s:
						s.add((k+1,l))
						q.append((k+1,l))

				if l > 0 and b[k][l-1] != '#':
					if (k,l-1) not in s:
						s.add((k,l-1))
						q.append((k,l-1))

				if l < m-1 and b[k][l+1] != '#':
					# print('yo')
					if (k,l+1) not in s:
						s.add((k,l+1))
						q.append((k,l+1))
			ncc += 1
	return ncc == 1

def solution(a,n,m):
	# a[n-1][m-1] = 'G'
	b = [['.' for _ in range(m)] for _ in range(n)]
	# print(a)
	seen_g = False
	for i in range(n):
		for j in range(m):
			if a[i][j] == 'G':
				seen_g = True
	if not seen_g:
		return "Yes"
	a[n-1][m-1] = 'G'
	for i in range(n):
		for j in range(m):
			if a[i][j] == '#':
				b[i][j] = '#'
			elif a[i][j] == 'B':
				b[i][j] = '#'
				if i > 0:
					if a[i-1][j] == 'G':
						return "No"
					b[i-1][j] = '#'

				if i < n-1:
					if a[i+1][j] == 'G':
						return "No"
					b[i+1][j] = '#'

				if j > 0:
					if a[i][j-1] == 'G':
						return "No"
					b[i][j-1] = '#'

				if j < m-1:
					if a[i][j+1] == 'G':
						return "No"
					b[i][j+1] = '#'

			elif a[i][j] == 'G':
				seen_g = True
				b[i][j] = 'G'

	return "Yes" if bfs(b,n,m) else "No"


def main():
	T = ri()
	for i in range(T):
		n,m = ria()
		a = []
		for _ in range(n):
			a.append(rs())

		x = solution(a,n,m)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			print >>output,str(x)# "Case #"+str(i+1)+':',
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()

if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
#example usage:
#    for l in res:
#       print >>output, str(len(l)) + ' ' +  ' '.join(l)

if __name__ == '__main__':
	main()