import math
import os
import random
import re
import sys

t = int(input())


def fill_has_path(i, j, n, m):
    if has_path == -1:
        if maze[i][j] in ['G', '.']:
            # top
            if i > 0 and has_path[i - 1][j] == True:
                has_path[i][j] = True
            # bottom
            if i < n - 1 and has_path[i + 1][j] == True:
                has_path[i][j] = True
            # right
            if j < m - 1 and has_path[i][j + 1] == True:
                has_path[i][j] = True
            # left
            if j > 0 and has_path[i][j - 1] == True:
                has_path[i][j] = True
        if has_path == -1:
            has_path[i][j] = False
        if i > 0:
            fill_has_path(i-1, j, n, m)
        if i < n-1:
            fill_has_path(i + 1, j, n, m)
        if j < m - 1:
            fill_has_path(i, j+1, n, m)
        if j > 0:
            fill_has_path(i, j-1, n, m)

while t > 0:
    t -= 1
    n, m = map(int, input().split())
    maze = []
    for i in range(n):
        maze.append(list(input()))

    # check if any G and B are adjecent
    no_way = False
    any_good = False
    for i in range(n):
        for j in range(m):
            if maze[i][j] == 'G':
                any_good = True
                # top
                if i > 0 and maze[i-1][j] == 'B':
                    no_way = True
                    break
                # bottom
                if i < n-1 and maze[i+1][j] == 'B':
                    no_way = True
                    break
                # right
                if j < m-1 and maze[i][j+1] == 'B':
                    no_way = True
                    break
                # left
                if j > 0 and maze[i][j-1] == 'B':
                    no_way = True
                    break
        if no_way:
            break
    if no_way:
        print("No")
        continue
    if not any_good:
        print("Yes")
        continue
    # block all the B
    for i in range(n):
        for j in range(m):
            if maze[i][j] == "B":
                # top
                if i > 0:
                    maze[i - 1][j] = '#'
                # bottom
                if i < n - 1:
                    maze[i + 1][j] = '#'
                # right
                if j < m - 1:
                    maze[i][j + 1] = '#'
                # left
                if j > 0:
                    maze[i][j - 1] = '#'
    if maze[n-1][m-1] == '#':
        print("No")
        continue
    # check if G still have a way to n,m
    has_path = [[-1 for __ in range(m)] for _ in range(n)]
    has_path[n-1][m-1] = True
    fill_has_path(n-1, m-1, n, m)
    for i in range(n):
        for j in range(m):
            if maze[i][j] == 'G' and has_path[i][j] != True:
                no_way = True
                break
        if no_way:
            break
    if no_way:
        print("No")
    else:
        print("Yes")
