import sys
from collections import defaultdict, deque
input = sys.stdin.readline

n, m, grid, adj, vis = [None] * 5

def solve():
    global n, m, grid
    n, m = map(int, input().strip().split())
    grid = [list(input().strip()) for i in range(n)]
    if grid[-1][-1] == 'B':
        print('No')
        return
    adj = defaultdict(list)

    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'B':
                if i + 1 < n:
                    if grid[i + 1][j] == 'G':
                        print('No')
                        return
                    else:
                        grid[i + 1][j] = '#'
                if i - 1 >= 0:
                    if grid[i - 1][j] == 'G':
                        print('No')
                        return
                    else:
                        grid[i - 1][j] = '#'
                if j + 1 < m:
                    if grid[i][j + 1] == 'G':
                        print('No')
                        return
                    else:
                        grid[i][j + 1] = '#'
                if j - 1 >= 0:
                    if grid[i][j - 1] == 'G':
                        print('No')
                        return
                    else:
                        grid[i][j - 1] = '#'
    # print(grid)
    
    for i in range(n):
        for j in range(m):
            if grid[i][j] != '#':
                if i + 1 < n:
                    if grid[i + 1][j] != '#':
                        adj[(i, j)].append((i + 1, j))
                        adj[(i + 1, j)].append((i, j))
                if i - 1 >= 0:
                    if grid[i - 1][j] != '#':
                        adj[(i, j)].append((i - 1, j))
                        adj[(i - 1, j)].append((i, j))
                if j + 1 < m:
                    if grid[i][j + 1] != '#':
                        adj[(i, j)].append((i, j + 1))
                        adj[(i, j + 1)].append((i, j))
                if j - 1 >= 0:
                    if grid[i][j - 1] != '#':
                        adj[(i, j)].append((i, j - 1))
                        adj[(i, j - 1)].append((i, j))
    
    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'G' and (i, j) != (n - 1, m - 1):
                vis = defaultdict(bool)
                q = deque()
                q.append((i, j))
                vis[(i, j)] = True
                exists = False
                while len(q) != 0 and not exists:
                    u = q.popleft()
                    for v in adj[u]:
                        if v == (n - 1, m - 1):
                            exists = True
                            break
                        if not vis[v]:
                            vis[v] = True
                            q.append(v)
                if not exists:
                    print('No')
                    return
    
    print('Yes')

def main():
    for _ in range(int(input().strip())):
        solve()

main()