def runTest(arr):
    Gs=set()
    Bs=set()
    #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 ((i!=i_ and j==j_) or (i==i_ and j!=j_)) and 0<=i_<len(arr) and 0<=j_<len(arr[0]) and \
                        arr[i_][j_]=='.': 
                            arr[i_][j_]='#'
                Bs.add((i,j))
            if arr[i][j]=='G':
                Gs.add((i,j))
#    print(arr)################
    #save which cells can escape
#    def canEscape(i,j,pathExploredSet):
#        if canEscapeCache[i][j]!=-1:
#            return canEscapeCache[i][j]
#        pathExploredSet.add((i,j))
#        if i==len(arr)-1 and j==len(arr[0])-1 and arr[i][j]!='#':
#            return True
#        else:
#            for i_ in (i-1,i,i+1):
#                    for j_ in (j-1,j,j+1):
#                        if ((i!=i_ and j==j_) or (i==i_ and j!=j_)) and 0<=i_<len(arr) and \
#                        0<=j_<len(arr[0]) and (i_,j_) not in pathExploredSet \
#                        and arr[i_][j_]!='#' and canEscape(i_,j_,pathExploredSet):
#                            canEscapeCache[i][j]=True
#                            return True
#        return False
#    canEscapeCache=[[-1 for _ in range(len(arr[0]))] for __ in range(len(arr))] #-1 default
#    canEscape(i,j,set())
    stack=[(len(arr)-1,len(arr[0])-1)] #perform dfs from (len(arr)-1,len(arr[0])-1)
    exploredSet=set()
    while stack:
        i,j=stack.pop()
        exploredSet.add((i,j))
        if (i,j) in Bs: #bad can reach end
            print('No')
            return
        if (i,j) in Gs:
            Gs.remove((i,j))
        for i_ in (i-1,i,i+1):
            for j_ in (j-1,j,j+1):
                if ((i!=i_ and j==j_) or (i==i_ and j!=j_)) and 0<=i_<len(arr) and \
                0<=j_<len(arr[0]) and (i_,j_) not in exploredSet \
                and arr[i_][j_]!='#':
                    stack.append((i_,j_))
    if len(Gs)==0: #all reached
        print('Yes')
    else:
        print('No')
    return
#2 5
#B.GGG
#.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)