from functools import lru_cache

def runTest(arr):
    #block all surroundings of B
    for i in range(len(arr)):
        for j in range(len(arr[0])):
            if arr[i][j]=='B':
                for i_ in (i-1,i,i+1):
                    for j_ in (j-1,j,j+1):
                        if not (i==i_ and j==j_) and 0<=i_<len(arr) and 0<=j_<len(arr[0]) and \
                        arr[i_][j_]=='.': 
                            arr[i_][j_]='#'
    #save which cells can escape
    @lru_cache(None)
    def canEscape(i,j):
        pathExploredSet.add((i,j))
        if i==len(arr)-1 and j==len(arr[0])-1:
            return True
        else:
            for i_ in (i-1,i,i+1):
                    for j_ in (j-1,j,j+1):
                        if not (i==i_ and j==j_) and 0<=i_<len(arr) and 0<=j_<len(arr[0]) and (i_,j_) not in pathExploredSet and canEscape(i_,j_):
                            return True
        return False
    for i in range(len(arr)-1,-1,-1):
        for j in range(len(arr[0])-1,-1,-1):
            pathExploredSet=set()
            canEscape(i,j)
    
    #check if all G can escape
    for i in range(len(arr)):
        ok=True
        for j in range(len(arr[0])):
            if arr[i][j]=='G' and canEscape(i,j)==False:
                ok=False
                break
        if ok==False:
            break
    if ok:
        print('Yes')
    else:
        print('No')


    
    
    
    
#2 2
##B
#G.
#Yes

t=int(input())

for _ in range(t):
    n,m=[int(z) for z in input().split()]
    arr=[]
    for __ in range(n):
        arr.append(list(input()))
    runTest(arr)