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:
'''input
6
1 1
.
1 2
G.
2 2
#B
G.
2 3
G.#
B#.
3 3
#B.
#..
GG.
2 2
#B
B.

'''
from collections import defaultdict
import math
from functools import reduce
from heapq import heapify, heappush, heappop
import sys
from sys import stdin, stdout
from random import seed
from random import randint


mod = 10 ** 9 + 7


def mul_mod(a, b):
    return ((a % mod) * (b % mod)) % mod


def add_mod(a, b):
    return ((a % mod) + (b % mod)) % mod

def sub_mod(a, b):
	return((a % mod) - (b % mod) + mod) % mod

def modInverse(b):
    # g = math.gcd(b, m)
    # if (g != 1):
    #     # print("Inverse doesn't exist")
    #     return -1
    return pow(b, mod - 2, mod)

def div_mod(a, b):
    a = a % mod
    inv = modInverse(b)
    # if(inv == -1):
    #     print("Division not defined")
    # else:
    #     print("Result of Division is ",(inv*a) % m)
    return (inv * a) % mod


# This class represents an undirected graph using adjacency list representation
class Graph:

    def __init__(self, vertices):
        self.V = vertices + 1  # No. of vertices
        self.graph = defaultdict(set)  # default dictionary to store graph
        self.Time = 0
        self.P = 0
        self.Q = 0

    # function to add an edge to graph
    def addEdge(self, u, v):
        self.graph[u].add(v)
        self.graph[v].add(u)

    '''A recursive function that finds and prints bridges
    using DFS traversal
    u --> The vertex to be visited next
    visited[] --> keeps tract of visited vertices
    disc[] --> Stores discovery times of visited vertices
    parent[] --> Stores parent vertices in DFS tree
    count[] --> Stores count of vertices in DFS subtree rooted at the vertex'''

    def bridgeUtil(self, u):
        # Mark the current node as visited and print it
        # self.visited[u] = True
        self.count[u] += 1

        # Initialize discovery time and low value
        self.disc[u] = self.Time
        self.low[u] = self.Time
        self.Time += 1

        # Recur for all the vertices adjacent to this vertex
        for v in self.graph[u]:
            # If v is not visited yet, then make it a child of u
            # in DFS tree and recur for it
            if self.count[v] == 0:
                self.parent[v] = u
                self.bridgeUtil(v)
                self.count[u] += self.count[v]

                # Check if the subtree rooted with v has a connection to
                # one of the ancestors of u
                self.low[u] = min(self.low[u], self.low[v])

                ''' If the lowest vertex reachable from subtree
                under v is below u in DFS tree, then u-v is
                a bridge'''
                if self.low[v] > self.disc[u]:
                    self.Q += 1
                    if self.count[v] % 2 == 0:
                        self.P += 1
                        # print("%d %d %d" % (u, v, count[v]))

            # Update low value of u for parent function calls.
            elif v != self.parent[u]:
                self.low[u] = min(self.low[u], self.disc[v])

    # DFS based function to find all bridges. It uses recursive
    # function bridgeUtil()
    def bridge(self):

        # Mark all the vertices as not visited and Initialize parent and visited,
        # and ap(articulation point) arrays
        # self.visited = [False] * (self.V)
        self.disc = [float("Inf")] * (self.V)
        self.low = [float("Inf")] * (self.V)
        self.parent = [-1] * (self.V)
        self.count = [0] * (self.V)

        # Call the recursive helper function to find bridges
        # in DFS tree rooted with vertex 'i'
        for i in range(1, self.V):
            if self.count[i] == 0:
                self.bridgeUtil(i)
        # print(count)

move_x = [1, -1, 0, 0]
move_y = [0, 0, 1, -1]

for _ in range(int(input())):
    n, m = map(int, input().split())
    mat = []
    for i in range(n):
    	mat.append(list(input()))

    count_G = 0
    count_B = 0

    for i in range(n):
    	for j in range(m):
    		if mat[i][j] == 'G':
    			count_G += 1
    		elif mat[i][j] == 'B':
    			count_B += 1

    if count_G == 0:
    	print("Yes")
    	continue

    adjacent = False
    for i in range(n):
    	for j in range(m):
    		if mat[i][j] == 'G':
    			for k in range(4):
    				new_i = i + move_x[k]
    				new_j = j + move_y[k]
    				if (0 <= new_i < n) and (0 <= new_j < m) and mat[new_i][new_j] == 'B':
    					adjacent = True
    					break
    		if adjacent:
    			break
    	if adjacent:
    		break

    if adjacent:
    	print("No")
    	continue

    for i in range(n):
    	for j in range(m):
    		if mat[i][j] == 'B':
    			for k in range(4):
    				new_i = i + move_x[k]
    				new_j = j + move_y[k]
    				if (0 <= new_i < n) and (0 <= new_j < m) and mat[new_i][new_j] != 'B':
    					mat[new_i][new_j] = '#'
    					# print(new_i, new_j, "check")

    # print(mat)
    if mat[-1][-1] == '#':
    	print('No')
    	continue

    visited = [[False for j in range(m)] for i in range(n)]
    reachable = 0

    curr = [(n - 1, m - 1)]
    visited[n - 1][m - 1] = True
    l = 0
    idx = 0

    while l < len(curr):
    	l = len(curr)
    	# print(curr)
    	while idx < l:
    		i, j = curr[idx]
    		idx += 1
    		if mat[i][j] == 'G':
    			reachable += 1

    		for k in range(4):
    			new_i = i + move_x[k]
    			new_j = j + move_y[k]
    			if (0 <= new_i < n) and (0 <= new_j < m) and mat[new_i][new_j] != '#' and not visited[new_i][new_j]:
    				visited[new_i][new_j] = True
    				curr.append((new_i, new_j))

    if count_G == reachable:
        # print('here I am', visited, count_G)
        print("Yes")
    else:
        # print("Damn", visited, count_G, reachable)
        print("No")