from itertools import accumulate as ac
from collections import Counter as cc
from bisect import bisect_left as bsl
from bisect import bisect as bs
from math import factorial as f
from collections import *
from itertools import *
from string import *
from bisect import *
from queue import *
from heapq import *
from math import *
from sys import *
from re import *
def fast(): return stdin.readline().strip()
def zzz(): return [int(i) for i in fast().split()]


z, zz = input, lambda: list(map(int, z().split()))
szz, graph, mod, szzz = lambda: sorted(
    zz()), {}, 10**9 + 7, lambda: sorted(zzz())


def lcd(xnum1, xnum2): return (xnum1 * xnum2 // gcd(xnum1, xnum2))
def output(answer): stdout.write(str(answer))


###########################---Test-Case---#################################
"""

  If you Know me , Then you probably don't know me !


"""
###########################---START-CODING---##############################

RED = (255, 0, 0)
WHITE = (0, 0, 0)


class Spot(object):
    """docstring for Spot miloy """

    def __init__(self, pos_x, pos_y, total_rows, total_cols,color):
        self.col = pos_y
        self.row = pos_x
        self.total_rows = total_rows
        self.total_cols = total_cols
        self.neighbors = []
        self.color = color

    def get_pos(self):
        return self.row, self.col

    def make_barierr(self):
        self.color = RED

    def update_neighbors(self, grids, is_barierr):
        self.neighbors = []

        if self.row > 0 and grids[self.row - 1][self.col].color != RED:  # UP
            self.neighbors.append(grids[self.row - 1][self.col])
        if self.row < self.total_rows - 1 and grids[self.row + 1][self.col].color != RED:  # DOWN
            self.neighbors.append(grids[self.row + 1][self.col])
        if self.col > 0 and grids[self.row][self.col - 1].color != RED:  # LEFT
            self.neighbors.append(grids[self.row][self.col - 1])
        if self.col < self.total_cols - 1 and grids[self.row][self.col + 1].color != RED:  # right
            self.neighbors.append(grids[self.row][self.col + 1])

        if is_barierr:
            for i in self.neighbors:
                i.make_barierr()
               
        # if self.row>0 and self.col>0:
        #   self.neighbors.append(grids[self.row-1][self.col-1])
        # if self.row < self.total_rows -1 and self.col < self.total_rows -1:
        #   self.neighbors.append(grids[self.row+1][self.col+1])
        # if self.row>0 and self.col<self.total_rows-1:
        #   self.neighbors.append(grids[self.row -1][self.col +1])
        # if self.row<self.total_rows-1 and self.col > 0:
        #   self.neighbors.append(grids[self.row+1][self.col -1])


def h(p1, p2):
    x1, y1 = p1
    x2, y2 = p2
    return abs(x1 - x2) + abs(y1 - y2)


def make_grids(rows, cols):
    grids = []
    for i in range(rows):
        grids.append([])
        for j in range(cols):
            grids[i].append(Spot(i, j, rows, cols,WHITE))
    return grids


def algo(grids, start, end):
    cnt = 0
    open_set = PriorityQueue()
    open_set.put((0, cnt, start))
    came_from = {}
    g_score = {spot: float("inf") for row in grids for spot in row}
    g_score[start] = 0
    f_score = {spot: float("inf") for row in grids for spot in row}
    f_score[start] = h(start.get_pos(), end.get_pos())
    open_set_hash = {start}

    while not open_set.empty():
        current = open_set.get()[2]
        open_set_hash.remove(current)
        if current == end:
            return True

        for neighbor in current.neighbors:
            temp_g_score = g_score[current] + 1
            if temp_g_score < g_score[neighbor]:
                came_from[neighbor] = current
                g_score[neighbor] = temp_g_score
                f_score[neighbor] = temp_g_score + h(neighbor.get_pos(), end.get_pos())
                if neighbor not in open_set_hash:
                    cnt += 1
                    open_set.put((f_score[neighbor], cnt, neighbor))
                    open_set_hash.add(neighbor)
    return False


num = int(z())

for _ in range(num):
    n, m = zzz()
    lst = []
    for i in range(n):
        lst.append(list(fast()))

    grids = make_grids(n, m)
    for i in range(n):
        for j in range(m):
            if lst[i][j] == "B":
                grids[i][j].update_neighbors(grids, True)
            elif lst[i][j] == "#":
                grids[i][j].make_barierr()

    for i in range(n):
        for j in range(m):
            if lst[i][j] == "G" or lst[i][j]=='.':
                grids[i][j].update_neighbors(grids, False)

    end = grids[n - 1][m - 1]
    res = True
    for i in range(n):
        for j in range(m):
            if lst[i][j] == "G":
                start = grids[i][j]
                res = algo(grids, start, end)
                if not res:
                    break
        if not res:
            break
    print("Yes" if res else "No")

