# https://codeforces.com/contest/1365/problem/D
from collections import deque
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
# do magic here

grid = [[0 for x in range(55)] for y in range(55)]

DX = [0, 1, 0, -1]
DY = [1, 0, -1, 0]


def bfs(n, m, badGuy, goodGuy):
    visited = [[0 for x in range(m)] for y in range(n)]
    q = deque([[n-1, m-1]])
    visited[n-1][m-1] = 1
    while len(q):
        x, y = q.popleft()
        if badGuy and grid[x][y] == 'B':
            return "No"
        if goodGuy and grid[x][y] == 'G':
            grid[x][y] = '.'
        for dx, dy in zip(DX, DY):
            if 0 <= x+dx < n and 0 <= y+dy < m:
                if grid[x+dx][y+dy] != '#' and not visited[x+dx][y+dy]:
                    visited[x+dx][y+dy] = True
                    q.append([x+dx, y+dy])
    for x in range(n):
        for y in range(m):
            if grid[x][y] == 'G':
                return "No"
    return "Yes"


def solve(n, m):

    badGuy = False
    goodGuy = False
    for x in range(n):
        for y in range(m):
            if grid[x][y] == 'B':
                badGuy = True
                for dx, dy in zip(DX, DY):
                    if 0 <= x+dx < n and 0 <= y+dy < m:
                        if grid[x+dx][y+dy] == 'G':
                            return "No"
                        if grid[x+dx][y+dy] == '.':
                            grid[x+dx][y+dy] = '#'
            if grid[x][y] == 'G':
                goodGuy = True

    if not goodGuy:
        return "Yes"
    return bfs(n, m, badGuy, goodGuy)


t = int(input())
for _ in range(t):
    n, m = map(int, input().split())
    for x in range(n):
        temp = input()
        for y in range(m):
            grid[x][y] = temp[y]
    print(solve(n, m))
