from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------

sys.setrecursionlimit(10**4)

dx = [1,-1,0,0]
dy = [0,0,1,-1]
for _ in range(int(input())):
    n,m = mapi()
    mat = []
    for i in range(n):
        mat.append(list(input().strip()))
    good=0
    for i in range(n):
        good+=mat[i].count("G")
    if good==0:
        print("Yes")
        continue
    vis = [[0]*m for i in range(n)]
    f = 0
    for i in range(n):
        for j in range(m):
            if mat[i][j]=="G":
                for k in range(4):
                    xx = i+dx[k]
                    yy = j+dy[k]
                    if 0<=xx<n and 0<=yy<m and mat[xx][yy]=="B":
                        f = 1
                        break
                if f:
                    break
        if f:
            break
    if f:
        print("No")
        continue
    for i in range(n):
        for j in range(m):
            if mat[i][j]=="B":
                for k in range(4):
                    xx = i+dx[k]
                    yy = j+dy[k]
                    if 0<=xx<n and 0<=yy<m and (mat[xx][yy]=="." or mat[xx][yy]=="G"):
                        mat[xx][yy] = "#"
    def dfs(i,j):
        if mat[i][j] =="#":return
        vis[i][j] = 1
        for k in range(4):
            xx = i+dx[k]
            yy = j+dy[k]
            if 0<=xx<n and 0<=yy<m and mat[xx][yy]!="#" and vis[xx][yy]==0:
                dfs(xx,yy)
    dfs(n-1,m-1)
    for i in range(n):
        for j in range(m):
            if mat[i][j]=="G" and vis[i][j]==0:
                f = 1
                break
        if f:
            break
    print("No" if f else "Yes" )

