'''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")




