from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))

def nbrs(i, j, r, c):
    if i > 0:
        yield (i - 1, j)
    if i < r - 1:
        yield (i + 1, j)
    if j > 0:
        yield (i, j - 1)
    if j < c - 1:
        yield (i, j + 1)
    return

def solve():
    rows, cols = rl()
    grid = []
    for i in range(rows):
        grid.append(list(input()))

    if grid[rows-1][cols-1] == "B":
        print ("No")
        return

    goods = 0
    for i in range(rows):
        for j in range(cols):
            if grid[i][j] == "B":
                for nbr in nbrs(i, j, rows, cols):
                    x, y = nbr
                    if grid[x][y] == "G":
                        print ("No")
                        return
                    elif grid[x][y] == ".":
                        grid[x][y] = "#"

            elif grid[i][j] == "G":
                goods += 1

    if goods == 0:
        print ("Yes")
        return
    elif grid[rows-1][cols-1] == "#":
        print ("No")
        return

    curr = [(rows - 1, cols - 1)]
    seen = set(curr)
    while curr:
        nxt = []
        for pair in curr:
            for nbr in nbrs(*pair, rows, cols):
                x, y = nbr
                if grid[x][y] not in [".", "G"]:
                    continue
                if nbr not in seen:
                    seen.add(nbr)
                    nxt.append(nbr)
                    if grid[nbr[0]][nbr[1]] == "G":
                        goods -= 1
        curr = nxt

    if goods == 0:
        print ("Yes")
    else:
        print ("No")




mode = 'T'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()
