#from sys import setrecursionlimit as srl
import sys
if sys.subversion[0] == "PyPy":
    import io, atexit
    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
    
    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
mod = 10**9+7
RS = raw_input
RI = lambda x=int: map(x,RS().split())
RN = lambda x=int: x(RS())
''' ...................................................................... '''

def removeBad(mat,n,m):
    for i in xrange(1,n+1):
        for j in xrange(1,m+1):
            if mat[i][j]=='B':
                mat[i][j] = '#'     # check
                
                if mat[i-1][j]=='G':
                    return 0
                else: mat[i-1][j]='#'
                
                if mat[i][j-1]=='G':
                    return 0
                else: mat[i][j-1]='#'

                if mat[i+1][j]=='G':
                    return 0
                elif mat[i+1][j]!='B':
                    mat[i+1][j]='#'

                if mat[i][j+1]=='G':
                    return 0
                elif mat[i][j+1]!='B':
                    mat[i][j+1]='#'
    return 1

def dfs(mat,n,m):
    def valid(x,y):
        if x<1 or x>n: return 0
        if y<1 or y>m: return 0
        return mat[x][y]!='#' and vis[x][y]==0
    
    vis = [[0]*(m+2) for i in xrange(n+2)]
    X = [-1,0,1,0]
    Y = [0,-1,0,1]
    st = [(n,m)]
    vis[n][m] = 1
    cnt = 0
    
    while st:
        x,y = st.pop()
        if mat[x][y]=='G':
            cnt+=1
            
        for i in range(4):
            a,b = x+X[i],y+Y[i]
            if valid(a,b):
                vis[a][b] = 1
                st.append((a,b))
    return cnt            
            
def solve():
    n,m = RI()
    wall = ['#']*(m+2)
    mat = [wall] + [['#']+list(RS())+['#'] for i in xrange(n)]
    mat.append(wall)
    
    good,bad = 0,0

    for i in xrange(1,n+1):
        for j in xrange(1,m+1):
            if mat[i][j]=='G':
                good+=1
            elif mat[i][j]=='B':
                bad+=1
                
    if good==0: return 1
    if bad and removeBad(mat,n,m)==0:
        return 0
    if mat[i][j]=='#': return 0

    return good==dfs(mat,n,m)


for _ in xrange(RN()):
    print ('yes' if solve() else 'no')
    
