t = int(input())

for _ in range(t):
    n, m = map(int, input().split())
    k = [[c for c in input()] for _ in range(n)]
    d = [[False for _ in range(m)] for _ in range(n)]


    def dfs(i, j):
        d[i][j] = True
        if i > 0 and not d[i - 1][j] and d[i - 1][j] != '#':
            dfs(i - 1, j)
        if i < n - 1 and not d[i + 1][j] and d[i + 1][j] != '#':
            dfs(i + 1, j)
        if j > 0 and not d[i][j - 1] and d[i][j - 1] != '#':
            dfs(i, j - 1)
        if j < m - 1 and not d[i][j + 1] and d[i][j + 1] != '#':
            dfs(i, j + 1)


    def checkOne():
        for i in range(n):
            for j in range(m):
                if k[i][j] == "B":
                    if i > 0:
                        if k[i - 1][j] == "G":
                            return False
                        if k[i - 1][j] == ".":
                            k[i - 1][j] = "#"
                    if j > 0:
                        if k[i][j - 1] == "G":
                            return False
                        if k[i][j - 1] == ".":
                            k[i][j - 1] = "#"
                    if i < n - 1:
                        if k[i + 1][j] == "G":
                            return False
                        if k[i + 1][j] == ".":
                            k[i + 1][j] = "#"
                    if j < m - 1:
                        if k[i][j + 1] == "G":
                            return False
                        if k[i][j + 1] == ".":
                            k[i][j + 1] = "#"

        if k[n - 1][m - 1] != '#':
            dfs(n - 1, m - 1)

        for i in range(n):
            for j in range(m):
                if k[i][j] == "G":
                    if not d[i][j]:
                        return False

        return True


    print("Yes" if checkOne() else "No")
