# python3 q4.py < test.txt
import collections
t = int(input())

for i in range(t):
    n, m = map(int, input().split())
    matrix = []
    fail = False
    num_g = 0
    for j in range(n):
        matrix.append(list((input())))
    
    
    directions = [ (0,1),(0,-1),(1,0),(-1,0) ]
    for i in range(n):
        for j in range(m):
            if matrix[i][j]=='G':
                num_g += 1
            elif matrix[i][j] == 'B':
                for di, dj in directions:
                    if di+i < 0 or di+i >=n or dj+j < 0 or dj+j >= m or matrix[di+i][dj+j] == 'B':
                        continue
                    elif matrix[di+i][dj+j] == 'G' :
                        fail = True
                        break
                    matrix[di+i][dj+j] = '#'
    
    
    if num_g == 0:
        print('Yes')
        continue
    if matrix[n - 1][m - 1] == '#' or fail == True:
        print('No')
        continue
    else:
        directions = [(0,1),(0,-1),(1,0),(-1,0)]
        q = collections.deque()
        q.append((n-1,m-1))
        matrix[n-1][m-1] = '#'
        while q:
            i, j  = q.popleft()
            for di, dj in directions:
                
                if di+i < 0 or di+i >=n or dj+j < 0 or dj+j >= m or matrix[di+i][dj+j] == '#':
                    continue
                if matrix[di+i][dj+j] == 'G':
                    num_g -= 1
                if matrix[di+i][dj+j] == 'B':
                    fail = True
                    break
                matrix[di+i][dj+j] = '#'
                q.append((di+i, dj+j))

        if fail == True:
            print('No')
            continue
        if num_g == 0:
            print('Yes')
            continue
        else:
            print('No')
            continue