def main():
    T=int(input())
    for _ in range(T):
        N,M=map(int,input().split())
        A=[]
        for _ in range(N):
            A.append(list(input()))
        for i in range(N):
            for j in range(M):
                if A[i][j]=='B':
                    if (i-1)>=0:
                        if A[i-1][j]=='.':
                            A[i-1][j]='#'
                    if (i+1)<N:
                        if A[i+1][j]=='.':
                            A[i+1][j]='#'
                    if (j-1)>=0:
                        if A[i][j-1]=='.':
                            A[i][j-1]='#'
                    if (j+1)<M:
                        if A[i][j+1]=='.':
                            A[i][j+1]='#'
        visited=[[False for i in range(M)] for j in range(N)]
        queue=[(N-1,M-1)]
        while(queue!=[]):
            first=queue[0]
            del queue[0]
            i,j=first[0],first[1]
            if i==(N-1) and j==(M-1) and A[i][j]=='#':
                visited[i][j]=False
            else:
                visited[i][j]=True
            if (i-1)>=0:
                if A[i-1][j]!='#' and visited[i-1][j]==False:
                    queue.append((i-1,j))
            if (i+1)<N:
                if A[i+1][j]!='#' and visited[i+1][j]==False:
                    queue.append((i+1,j))
            if (j-1)>=0:
                if A[i][j-1]!='#' and visited[i][j-1]==False:
                    queue.append((i,j-1))
            if (j+1)<M:
                if A[i][j+1]!='#' and visited[i][j+1]==False:
                    queue.append((i,j+1))
        escapePossibility=True
        for i in range(N):
            for j in range(M):
                if (A[i][j]=='G' and visited[i][j]==False) or (A[i][j]=='B' and visited[i][j]==True):
                    escapePossibility=False
                    break
            if not escapePossibility:
                break
        if escapePossibility:
            print("Yes")
        else:
            print("No")
if __name__=='__main__':
    main()  
