# https://codeforces.com/contest/1365/problem/D


def get_valid_neighbours(M, V, r, c):
    dr = [0, 0, -1, +1]
    dc = [-1, +1, 0, 0]
    D = list(zip(dr, dc))

    neighbours = []

    for dr, dc in D:
        R = r + dr
        C = c + dc

        if (0 <= R < len(M)) and (0 <= C < len(M[0])) and not V[R][C]:
            if M[R][C] != '#':
                neighbours.append([R, C])

    return neighbours


def inspect(M, visited, WALL, r, c):
    dr = [0, 0, -1, +1]
    dc = [-1, +1, 0, 0]
    D = list(zip(dr, dc))

    for dr, dc in D:
        R = r + dr
        C = c + dc

        if (0 <= R < len(M)) and (0 <= C < len(M[0])) and not visited[R][C] and not WALL[R][C]:
            if M[R][C] == "G":
                return "No"
            elif M[R][C] in [".", "#"]:
                visited[R][C] = True
                M[R][C] = '#'
                WALL[R][C] = True


def eval(M, R, C):
    visited = [[False for _ in range(C)] for _ in range(R)]
    GOOD = []
    WALL = [[False for _ in range(C)] for _ in range(R)]

    for r in range(R):
        for c in range(C):
            if not visited[r][c]:
                visited[r][c] = True
                if M[r][c] == '#':
                    WALL[r][c] = True
                elif M[r][c] == 'G':
                    GOOD.append([r, c])
                elif not visited[r][c] and M[r][c] == 'B':
                    ans = inspect(M, visited, WALL, r, c)
                    if ans and ans == "No":
                        return "No"

    if len(GOOD) > 0:
        # Now you check the r-1, c-1
        n, m = R-1, C-1
        dr = [0, 0, -1, +1]
        dc = [-1, +1, 0, 0]
        D = list(zip(dr, dc))

        # detect if there is a wall around the exit point:
        detect_wall = []
        count = 0

        for dr, dc in D:
            NN = n + dr
            MM = m + dc

            if (0 <= NN < len(M)) and (0 <= MM < len(M[0])):
                count += 1
                if M[NN][MM] == 'B':
                    return "No"
                elif M[NN][MM] == '#':
                    detect_wall.append('#')

        # validate if exit is possible at all:
        if len(detect_wall) == count:
            return 'No'

        for P in GOOD:
            visited = [[False for _ in range(C)] for _ in range(R)]
            Q = []
            Q.append(P)
            success = False

            while len(Q) > 0:
                newQ = []
                for p in Q:
                    r, c = p
                    if r == R - 1 and c == C - 1:
                        success = True
                        break
                    else:
                        visited[r][c] = True
                        newQ += get_valid_neighbours(M, visited, r, c)
                Q = newQ

            if not success:
                return "No"

    return "Yes"


# receive the input:
for i in range(int(input())):
    R, C = list(map(int, input().split()))
    M = []
    for _ in range(R):
        M.append(list(input()))
    print(eval(M, R, C))
