import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]
def main():
    for _ in range(int(input())):
        n, m = map(int,input().split())
        G = [["#"]+[s for s in input()]+["#"] for k in range(n)]
        G = [["#"]*(m+2)] + G + [["#"]*(m+2)]
        flag = 0
        dx = [1,0,-1,0]
        dy = [0,1,0,-1]
        start = []
        for y in range(1,n+1):
            for x in range(1,m+1):
                if G[y][x] == "B":
                    for k in range(4):
                        if G[y+dy[k]][x+dx[k]] == "G":
                            flag = 1
                            break
                        elif G[y+dy[k]][x+dx[k]] == ".":
                             G[y+dy[k]][x+dx[k]] = "#"
                elif G[y][x] == "G":
                    start.append([y,x,0])
        if len(start) == 0:
            flag = 0
        else:
            if G[n][m] == "#":
                flag = 1
            else:
                dist = [[10**9]*(m+2) for k in range(n+2)]
                Q = deque([[n,m,0]])
                dist[n][m] = 0
                while len(Q) > 0:
                    ima = Q.popleft()
                    for k in range(4):
                        if G[ima[0]+dy[k]][ima[1]+dx[k]] == "." or G[ima[0]+dy[k]][ima[1]+dx[k]] == "G":
                            if dist[ima[0]+dy[k]][ima[1]+dx[k]] > ima[2]+1:
                                dist[ima[0]+dy[k]][ima[1]+dx[k]] = ima[2]+1
                                Q.append([ima[0]+dy[k],ima[1]+dx[k],ima[2]+1])
                for e in start:
                    if dist[e[0]][e[1]] == 10**9:
                        flag = 1
                        break
        print("No" if flag == 1 else "Yes")
if __name__ == '__main__':
    main()
