import queue
T = int(input())
for t in range(0,T):
    l = input().split()
    n = int(l[0])
    m = int(l[1])
    maze = []
    for i in range(0,n):
        maze.append(list(input().strip()))

    good = True
    total = 0

    coord = [(-1,0),(1,0), (0,-1), (0,1)]
    for i in range(0,n):
        if not good:
            break
        for j in range(0,m):
            if maze[i][j] == 'B':
                for k in range(0,4) :
                    if 0 <= i +coord[k][0]  < n and 0 <= j +coord[k][1] < m :
                        if maze[i +coord[k][0]][j +coord[k][1]] == '.':
                            maze[i +coord[k][0]][j +coord[k][1]] = '#'
            elif maze[i][j] == 'G':
                total += 1
    if not good:
        print("No")
        continue
    count = 0
    q = queue.Queue()
    if maze[n-1][m-1] !='#':
        q.put((n-1,m-1))

    found = set([])
    while not q.empty():
        t = q.get()
        for p in coord:
            nc = (t[0]+p[0], t[1] + p[1])
            if nc[0] >= 0 and nc[0] < n and nc[1] >=0 and nc[1] < m and nc not in found:
                if maze[nc[0]][nc[1]] == 'G':
                    count +=1
                    q.put(nc)
                elif maze[nc[0]][nc[1]] == '.' or maze[nc[0]][nc[1]] == 'B':
                    q.put(nc)
            found.add(nc)
    if count == total:
        print("Yes")
    else:
        print("No")


