# python rough_work.py < in > out && cat out && diff -qs out check
t = int(input())

for k in range(t):
    # print("test %d"%(k+1))
    n, m = (int(var) for var in input().split())
    maze = []
    for _ in range(n):
        maze.append([var for var in input()])

    goodBoys, flag, temp = 0, True, ("B", "G")
    # print("maze", maze)

    for row in range(n):
        if flag is False:
            break
        for col in range(m):
            if maze[row][col] == "B":
                if row-1 >= 0 :
                    if maze[row-1][col] not in temp:
                        maze[row-1][col] = "#"
                    elif maze[row-1][col] == "G":
                        flag = False
                        break 
                if row+1 < n :
                    if maze[row+1][col] not in temp:
                        maze[row+1][col] = "#"
                    elif maze[row+1][col] == "G":
                        flag = False
                        break
                if col + 1 < m:
                    if maze[row][col+1] not in temp:
                        maze[row][col+1] = "#"
                    elif maze[row][col+1] == "G":
                        flag = False
                        break
                if col - 1 >= 0:
                    if maze[row][col-1] not in temp:
                        maze[row][col-1] = "#"
                    elif maze[row][col-1] == "G":
                        flag = False
                        break
            elif maze[row][col] == "G":
                goodBoys += 1

    # print("ans for maze", maze, flag)

    if goodBoys == 0 and flag is True:
        # print(" gB = 0 Yes")
        print("Yes")
    elif flag is False or maze[n-1][m-1]!=".":
        # print(" flag is False or wall at exit No")
        print("No")
    else:
        stack = [(n-1, m-1)] 
        visited = {(n-1, m-1):1}
        while len(stack) != 0 and goodBoys != 0:
            row, col = stack.pop()
            if row-1 >= 0 and (row-1, col) not in visited:
                visited[row-1, col] = 1
                if maze[row-1][col] == "G":
                    goodBoys -= 1
                    stack.append((row-1, col))
                elif maze[row-1][col] == ".":
                    stack.append((row-1, col))

            if row + 1 < n and (row+1, col) not in visited:
                visited[row+1, col] = 1
                if maze[row+1][col] == "G":
                    goodBoys -= 1
                    stack.append((row+1, col))
                elif maze[row+1][col] == ".":
                    stack.append((row+1, col))

            if col - 1 >= 0 and (row, col-1) not in visited:
                visited[row, col-1] = 1
                if maze[row][col-1] == "G":
                    goodBoys -= 1
                    stack.append((row, col-1))
                elif maze[row][col-1] == ".":
                    stack.append((row, col-1))

            if col + 1 < m and (row, col+1) not in visited:
                visited[row, col+1] = 1
                if maze[row][col+1] == "G":
                    goodBoys -= 1
                    stack.append((row, col+1))
                elif maze[row][col+1] == ".":
                    stack.append((row, col+1))

        print("Yes" if goodBoys == 0 else "No")

