import io
import os

from collections import Counter, defaultdict, deque


drdc = [(-1, 0), (0, -1), (0, 1), (1, 0)]
def solve(R, C, grid):

    goodCount = 0
    for r in range(R):
        for c in range(C):
            if grid[r][c] == 'G':
                goodCount += 1
            if grid[r][c] == 'B':
                for dr, dc in drdc:
                    nr = r + dr
                    nc = c + dc
                    if 0 <= nr < R and 0 <= nc < C:
                        if grid[nr][nc] == 'G':
                            return 'No'
                        grid[nr][nc] = '#'

    if grid[R - 1][C - 1] in '#':
        return 'No'


    q = deque([(R - 1, C - 1)])

    seen = set()
    badCount = 0
    while q:
        r, c = q.popleft()
        if grid[r][c] == 'G':
            goodCount -= 1
        if grid[r][c] == 'B':
            badCount += 1
        for dr, dc in drdc:
            nr = r + dr
            nc = c + dc
            if 0 <= nr < R and 0 <= nc < C and (nr, nc) not in seen:
                if grid[nr][nc] in 'G.B':
                    q.append((nr, nc))
                    seen.add((nr, nc))

    if goodCount == 0 and badCount == 0:
        return 'Yes'
    return 'No'


if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    T = int(input())
    for t in range(T):
        N, M = [int(x) for x in input().split()]
        grid = [list(input().decode().rstrip()) for i in range(N)]
        ans = solve(N, M, grid)
        print(ans)
