import sys
sys.setrecursionlimit(100000)

Directions =[(-1, 0), (1, 0), (0, -1), (0, 1)]  #Posibles direcciones donde se puede encontrar los adyacentes a una casilla

def dfs(i, j): #Realizamos un dfs a partir de la casilla de salida para
    if i > n or i == 0 or j > m or j == 0:
        return
    visited[i][j] = 1
    for di, dj in Directions:
        if not visited[i + di][j + dj] and maze[i + di][j + dj] != "#":
            dfs(i + di, j + dj)

for t in range(int(input())):
    n, m = list(map(int, input().split()))
    maze = [["#"]*(m + 2)] + [list("#" + input() + "#")for i in range(n)] + [["#"]*(m + 2)]
    visited = [[0]*(m + 2) for i in range(n + 2)]
    canDoIt = True
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if maze[i][j] == "B":
                for di, dj in Directions:
                    if maze[i + di][j + dj] == "G":
                        canDoIt = False
                    elif maze[i + di][j + dj] != "B":
                        maze[i + di][j + dj] = "#"
    if maze[n][m] != "#":
        dfs(n, m)
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if maze[i][j] == "G" and not visited[i][j]:
                canDoIt = False
    print("Yes" if canDoIt else "No")