from collections import deque
from sys import stdin, stdout  
import math
input = stdin.readline
#print = stdout.write


for _ in range(int(input())):
    n, m = map(int, input().split())
    arr = [list(input().strip()) for i in range(n)]
    good = []
    bad = []
    for i in range(n):
        for g in range(m):
            if arr[i][g] == 'G':
                good.append((i, g))
            elif arr[i][g] == 'B':
                bad.append((i, g)) 
    dirs = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    can = True
    for i in bad:
        for g in dirs:
            newx = i[0] + g[0]
            newy = i[1] + g[1]
            if not (0 <= newx < n and 0 <= newy < m):
                continue
            if arr[newx][newy] == 'G':
                can = False
            if arr[newx][newy] == '.':
                arr[newx][newy] = '#'
    visited = [[0 for g in range(m)] for i in range(n)]
    buff = deque()
    if arr[n - 1][m - 1] != '#':
        visited[n - 1][m - 1] = 1
        buff = deque([(n - 1, m - 1)])
    while len(buff):
        i = buff.popleft()
        for g in dirs:
            newx = i[0] + g[0]
            newy = i[1] + g[1]
            if not (0 <= newx < n and 0 <= newy < m) or visited[newx][newy] or arr[newx][newy] == '#':
                continue
            visited[newx][newy] = 1
            buff.append((newx, newy))
    for i in good:
        if not visited[i[0]][i[1]]:
            can = False
    for i in bad:
        if visited[i[0]][i[1]]:
            can = False
    print('Yes' if can else 'No')
