from collections import deque
def solve():
    n, m = map(int, input().split())
    s = []
    for _ in range(n):
        s.append(list(input()))
    dxdy = [(-1,0),(0,-1),(0,1),(1,0)]
    for y in range(n):
        for x in range(m):
            if s[y][x]=='B':
                for dx, dy in dxdy:
                    if not (0<=x+dx<m and 0<=y+dy<n):
                        continue
                    if s[y+dy][x+dx]=='G':
                        print('No')
                        return
                    if s[y+dy][x+dx]=='.':
                        s[y+dy][x+dx] = '#'
                s[y][x] = '#'
    if s[n-1][m-1]=='#':
        q = []
    else:
        q = deque([(m-1, n-1)])
    while q:
        x, y = q.popleft()
        for dx, dy in dxdy:
            if not (0<=x+dx<m and 0<=y+dy<n):
                continue
            if s[y+dy][x+dx] in ['#', 'seen']:
                continue
            s[y+dy][x+dx] = 'seen'
            q.append((x+dx, y+dy))
    for i in s:
        if i.count('G'):
            print('No')
            return
    print('Yes')
t = int(input())
for _ in range(t):
    solve()
