from sys import stdin, gettrace
from collections import deque

if gettrace():
    inputi = input
else:
    def input():
        return next(stdin)[:-1]


    def inputi():
        return stdin.buffer.readline()


def main():
    def solve():

        n,m = map(int, input().split())
        maze = []
        for _ in range(n):
            maze.append(list(input()))
        gcount = 0
        for i in range(n):
            for j in range(m):
                if maze[i][j] == 'B':
                    adj = [(i - 1, j),
                           (i, j - 1),
                           (i + 1, j),
                           (i, j + 1)]
                    for z, w in adj:
                        if 0 <= z < n and 0 <= w < m and maze[z][w] == '.':
                            maze[z][w] = '#'
                elif maze[i][j] == 'G':
                    gcount += 1
        visited = [[False] * m for _ in range(n)]
        if maze[n-1][m-1] =='#':
            if gcount == 0:
                print('Yes')
            else:
                print('No')
            return
        dq = deque()
        dq.append((n-1, m-1))
        visited[n-1][m-1] = True
        while dq:
            x, y = dq.pop()
            adj = [(x-1,y), (x, y-1), (x+1, y), (x, y+1)]
            for z, w in adj:
                if 0 <= z < n and 0 <= w < m and not visited[z][w] and maze[z][w] != '#':
                    if maze[z][w] == 'G':
                        gcount -= 1
                    elif maze[z][w] == 'B':
                        print('No')
                        return
                    visited[z][w] = True
                    dq.append((z, w))
        if gcount == 0:
            print("Yes")
        else:
            print('No')


    q = int(inputi())
    for _ in range(q):
        solve()


if __name__ == "__main__":
    main()