from collections import deque
import sys
input = sys.stdin.readline
def bounds(x, y, n, m):
    return (0<=x<n) and (0<=y<m)
t = int(input())
for _ in range(t):
    n, m = map(int, input().split())
    grid = []
    for i in range(n):
        grid.append(list(input().strip()))
    dirs = [[1, 0], [-1, 0], [0,-1], [0, 1]]
    for i in range(n):
        for j in range(m):
            if (grid[i][j] == 'B'):
                for a, b in dirs:
                    i2 =i+ a
                    j2 =j+ b
                    if bounds(i2, j2, n, m) and grid[i2][j2] != 'G' and grid[i2][j2] != 'B':
                        grid[i2][j2] = '#'
    visited = [[0 for i in range(m)] for j in range(n)]
    dq = deque([[n-1, m-1]])
    while dq:
        x, y = dq.popleft()
        visited[x][y] = 1
        if grid[x][y] == '#':
            continue
        for a, b in dirs:
            nx = x+a
            ny = y+b
            if bounds(nx, ny, n, m) and not(visited[nx][ny]) and grid[nx][ny] !='#' :
                visited[nx][ny] = 1
                dq.append([nx, ny])
    bad = False
    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'G' and not(visited[i][j]):
                bad = True
            elif grid[i][j] == 'B' and visited[i][j]:
                bad = True
    if bad:
        print("No")
    else:
        print("Yes")
