import sys
input = sys.stdin.readline
import math

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input().strip()
    return(list(s[:len(s)]))
def invr():
    return(map(int,input().strip().split()))



def from_file(f):
    return f.readline


def dfs(n, m, A, token, visited):
    # return the count of reachable G's
    if A[n-1][m-1] == '#':
        return 0
    def can_move(ni, nj):
        return 0 <= ni < n and 0 <= nj < m and A[ni][nj] not in ('#', 'B')

    count = 0
    stack = [(n-1, m-1)]
    visited[n-1][m-1] = token

    while stack:
        cur = stack.pop()
        i, j = cur
        if A[i][j] == 'G':
            count += 1

        for ni, nj in ((i+1, j), (i-1, j), (i, j+1), (i, j-1)):
            if can_move(ni, nj) and visited[ni][nj] != token:
                visited[ni][nj] = token
                stack.append((ni, nj))

    # print(f"Reaced{count}")
    return count



def check_neibs(n, m, i, j, A):
    for p, q in ((i+1, j), (i-1, j), (i, j+1), (i, j-1)):
        if 0 <= p < n and 0 <= q < m and A[p][q] != 'B':
            A[p][q] = '#'


def solution(n, m, A, visited, token):
    # count G:

   cG, cB = 0, 0
   for i, row in enumerate(A):
       for j, s in enumerate(row):
           if s == 'G':
               cG +=1

   for i, row in enumerate(A):
       for j, s in enumerate(row):
           if s == 'B':
               cB += 1
               check_neibs(n, m, i, j, A)

   if cG == 0:
       return 'Yes'
   rG = dfs(n, m, A, token, visited)

   if cG != rG:
       return 'No'

   return 'yes'



# with open('4.txt') as f:
#     input = from_file(f)
t = inp()
visited = [[-1] * 60 for _ in range(60)]
for token in range(t):
    n,m = invr()
    A = []
    for _ in range(n):
        A.append(list(input().strip()))
    print(solution(n, m, A, visited, token+1))