import sys
import math
import collections

sys.setrecursionlimit(10**6)

x = [0, 0, 1, -1]
y = [1, -1, 0, 0]
moves = list(zip(x, y))

def isValid(x, y, n, m):
    return x >= 0 and x < n and y >= 0 and y < m

def bfs(grid, x, y, n, m):
    for mo in moves:
        nx = x + mo[0]
        ny = y + mo[1]
        if isValid(nx, ny, n, m):
            if grid[nx][ny] == 'G' or grid[nx][ny] == '.':
                grid[nx][ny] = 'Y'
                bfs(grid, nx, ny, n, m)


t = int(sys.stdin.readline().strip())
for i in range(t):
    n, m = list(map(int,sys.stdin.readline().strip().split(' ')))
    grid = []
    hasGood = False
    for i in range(n):
        l = list(sys.stdin.readline().strip())
        if 'G' in l:
            hasGood = True
        grid.append(l)

    if not hasGood:
        print("Yes")
    else:

        isPossible = True
        for i in range(len(grid)):
            for j in range(len(grid[0])):
                if grid[i][j] == 'B':
                    for e in moves:
                        nx = i + e[0]
                        ny = j + e[1]
                        if isValid(nx, ny, n, m):
                            if grid[nx][ny] != 'G' and grid[nx][ny] != 'B':
                                grid[nx][ny] = '#'
                            elif grid[nx][ny] == 'G':
                                isPossible = False
                                break
                if not isPossible:
                    break
            if not isPossible:
                break

        if not isPossible:
            print("No")
        elif grid[n-1][m-1] == '#':
            print("No")
        else:
            bfs(grid, n-1, m-1, n, m)
            possible = True
            for i in range(len(grid)):
                for j in range(len(grid[0])):
                    if grid[i][j] == 'G':
                        possible = False
                        break
                if not possible:
                    break

            if possible:
                print("Yes")
            else:
                print("No")
