# findcount=0
def neighbours(a,b,maze,n,m):
    if maze[a][b] == '#':
        return []
    k=[(0,1),(1,0),(-1,0),(0,-1)]
    ans=[]
    for u,v in k :
        if (0 <= u+a < n) and (0 <= v+b < m):
            if maze[u+a][v+b] != '#':
                ans.append((u+a,v+b))
    
    return ans

def bfs(maze,n,m,gcount):
    findcount=0
    visited=[[False for i in range(m)] for j in range(n)]
    visited[n-1][m-1]=True
    queue=[(n-1,m-1)]
    while queue:
        a,b=queue.pop()
        if maze[a][b] == 'G':
            findcount+=1
        for p,q in neighbours(a,b,maze,n,m):
            if visited[p][q] == False:
                visited[p][q] = True
                queue.append((p,q))
    if findcount == gcount:
        return True
    else:
        return False
    
t=int(input())
for _ in range(t):
    n,m=[int(c) for c in input().split()]
    maze=[]
    gcount=0
    for i in range(n):
        arr=[c for c in input()]
        maze.append(arr)
        gcount+=arr.count('G')
    
    for i in range(n):
        for j in range(m):
            if maze[i][j] == 'B':
                for u,v in neighbours(i,j,maze,n,m):
                    if maze[u][v] == ".":
                        maze[u][v] = '#'
    if bfs(maze,n,m,gcount):
        print("Yes")
    else:
        print("No")