from sys import stdin, stdout

def isvalid(r, c, n, m):
    if r>=0 and r<= n-1 and c>=0 and c<=m-1:
        return True
    return False

def isvalid2(r, c, n, m):
    if r>=0 and r< n-1 and c>=0 and c< m-1:
        return True
    return False

def dfs(matrix, start, end, n, m):
    # return False if cannot reach end from start
    stack = []
    stack.append(start)
    visited = [[0]*m for _ in range(n)]

    while stack:
        r, c = stack.pop()
        visited[r][c] = 1
        if r == end[0] and c== end[1]:
            return True

        if isvalid(r-1, c, n, m) and not visited[r-1][c] and matrix[r-1][c] != '#':
            stack.append([r-1, c])
        if isvalid(r, c-1, n, m) and not visited[r][c-1] and matrix[r][c-1] != '#':
            stack.append([r, c-1])
        if isvalid(r+1, c, n, m) and not visited[r+1][c] and matrix[r+1][c] != '#':
            stack.append([r+1, c])
        if isvalid(r, c+1, n, m) and not visited[r][c+1] and matrix[r][c+1] != '#':
            stack.append([r, c+1])  

    return False

t = int(input())
for _ in range(t):
    n, m = map(int, stdin.readline().strip().split())
    matrix = []
    gloc, bloc = [], []
    for r in range(n):
        row = list(stdin.readline().strip())
        for c in range(m):
            if row[c] == 'B':
                bloc.append([r, c])
            elif row[c] == 'G':
                gloc.append([r, c])
        matrix.append(row)

    if len(gloc) == 0:
        print('Yes')

    elif len(bloc) == 0:
        ans = 'Yes'
        for start in gloc:
            if not dfs(matrix, start, [n-1, m-1], n, m):
                ans = 'No'
                break
        print(ans)
    
    elif len(gloc) == 0 and len(bloc) == 0:
        print('Yes')

    else:
        # good and bad
        for start in bloc:
            if dfs(matrix, start, [n-1, m-1], n, m):
                r, c = start
                if isvalid(r, c-1, n, m) and  matrix[r][c-1] == '.':
                    matrix[r][c-1] = '#'
                if dfs(matrix, start, [n-1, m-1], n, m) and isvalid(r-1, c, n, m) and matrix[r-1][c] == '.':
                    matrix[r-1][c] = '#'
                if dfs(matrix, start, [n-1, m-1], n, m) and isvalid(r+1, c, n, m) and matrix[r+1][c] == '.':
                    matrix[r+1][c] = '#'
                if dfs(matrix, start, [n-1, m-1], n, m) and isvalid(r, c+1, n, m) and matrix[r][c+1] == '.':
                    matrix[r][c+1] = '#'
                
        ans = 'Yes'
        for start in gloc:
            if not dfs(matrix, start, [n-1, m-1], n, m):
                ans = 'No'
                break
        print(ans)

        
        

    
    
